-
Notifications
You must be signed in to change notification settings - Fork 6
/
background.js
39 lines (30 loc) · 1010 Bytes
/
background.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
(function(){
if (!localStorage.letBlocks){
var item = Array(5);
item[0] = {str: 'A', clr: '#800000'}; //maroon
item[1] = {str: 'E',clr: '#008000'}; //green
item[2] = {str: 'I', clr: '#0000ff'}; //blue
item[3] = {str: 'O', clr:'#008080'}; //teal
item[4] = {str:'U',clr: '#800080'}; //purple
localStorage["letBlocks"] = JSON.stringify(item);
localStorage['saved'] = 'Y';
}
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if (request.method == "getColors"){
var letBlocks = JSON.parse(localStorage.letBlocks);
sendResponse(letBlocks);
} else if(request.method === "get_temp_disable") {
sendResponse({disabled:window.localStorage.temp_disable==="Y"});
} else if(request.method === 'toggle_temp_disable'){
if(window.localStorage.temp_disable === "Y"){
window.localStorage.temp_disable = null;
}
else{
window.localStorage.temp_disable = "Y";
}
sendResponse({suc:"success"});
} else {
sendResponse({}); // snub them.
}
});
})();