forked from whizzzkid/csc309-crext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbg.js
48 lines (42 loc) · 1.15 KB
/
bg.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
45
46
47
48
/**
* App namespace.
* @type {object}
*/
var YouTubeOnRepeatApp = {};
YouTubeOnRepeatApp.LOCAL_STORE_ID = 'YouTubeOnRepeatApp_StoreKey';
/**
* Message Listner
* @param {object} request
* @param {object} sender
* @param {object} respond
*/
youtubeOnRepeatApp.messageListener = function (request, sender, respond) {
console.log(request);
if (request.action == 'getRepeatUrl') {
console.log('Request I got:' + request);
console.log('Request was sent by: ' + sender);
respond({ repeatUrl: 'Some Response'});
}
};
/**
* Gets value from localStorage.
* @return {string} stored value.
*/
youtubeOnRepeatApp.getStoredValue = function () {
return localStorage[this.LOCAL_STORE_ID];
};
/**
* Stores the value to localStorage.
* @param {string} value
* @return {string} stored value.
*/
youtubeOnRepeatApp.setStoredValue = function (value) {
localStorage[this.LOCAL_STORE_ID] = value;
return this.getStoredValue();
};
YouTubeOnRepeatApp.init = function () {
console.log('I am Loaded!');
};
YouTubeOnRepeatApp.init();
// Setting up listeners
chrome.runtime.onMessage.addListener(youtubeOnRepeatApp.messageListener);