-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbackground.js
62 lines (53 loc) · 1.49 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function setDefaultSettings() {
var value = localStorage["scale"];
if(!value) {
localStorage["scale"] = 1.0;
}
value = localStorage["ioscompat"];
if(!value) {
localStorage["ioscompat"] = true;
}
value = localStorage["usefont"];
if(!value) {
localStorage["usefont"] = false;
}
value = localStorage["blacklist"];
if(!value) {
localStorage["blacklist"] = '';
}
}
function listener(request, sender, sendResponse) {
var response = $.extend(true, {}, request);
if(request.setting) {
var value = localStorage[request.setting];
response.result = value;
}
sendResponse(response);
}
function self_test() {
readCharDictionary(
function(dict) {
var items = dict.items;
for(var i = 0; i < items.length; i++) {
var item = items[i];
if(item.name == "") {
console.error(item);
} else if(item.id == "") {
console.error(item);
} else if (item.id.indexOf(' ') != -1) {
console.error(item);
} else if(item.image == "") {
console.error(item);
} else if (item.chars.length < 1) {
console.error(item);
}
}
console.log("Done.");
}
);
}
setDefaultSettings();
chrome.extension.onMessage.addListener(listener);
if(localStorage["debug"]) {
self_test();
}