-
Notifications
You must be signed in to change notification settings - Fork 4
/
popup_script.js
44 lines (38 loc) · 929 Bytes
/
popup_script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* App namespace.
* @type {object}
*/
var youtubeOnRepeatApp = {};
/**
* Click Handler.
*/
youtubeOnRepeatApp.clickHandler = function () {
this.sendMessageToBackground(
{ action: 'toggle' }, this.callback);
};
/**
* Callback method.
* @param {object} response
*/
youtubeOnRepeatApp.callback = function (response) {
var status = document.getElementById('all_status');
status.innerText = response.status;
};
/**
* Sends message to the background.
* @param {object} request
* @param {function} callback
*/
youtubeOnRepeatApp.sendMessageToBackground = function (request, callback) {
chrome.runtime.sendMessage(request, callback);
};
/**
* Init method.
*/
youtubeOnRepeatApp.init = function () {
console.log('I am Loaded!');
var button = document.getElementById('button');
button.addEventListener('click', this.clickHandler.bind(this));
};
// Init.
youtubeOnRepeatApp.init();