-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackground.html
53 lines (50 loc) · 2.18 KB
/
background.html
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
<html>
<head>
<script src="dict.js"></script>
<script src="main.js"></script>
<script>
chrome.browserAction.onClicked.addListener(zhongwenMain.enableToggle);
chrome.tabs.onSelectionChanged.addListener(zhongwenMain.onTabSelect);
chrome.extension.onRequest.addListener(
function(request, sender, response) {
switch(request.type) {
case 'enable?':
zhongwenMain.onTabSelect(sender.tab.id);
break;
case 'search':
var e = zhongwenMain.search(request.text);
response(e);
break;
case 'open':
chrome.tabs.create({url: request.url});
case 'copy':
var txt = document.createElement('textarea');
txt.style.position = "absolute";
txt.style.left = "-100%";
txt.value = request.data;
document.body.appendChild(txt);
txt.select();
document.execCommand('copy');
document.body.removeChild(txt);
default:
// ignore
}
});
function initStorage(key, defaultValue) {
var currentValue = localStorage[key];
if (!currentValue) {
localStorage[key] = defaultValue;
return true;
}
return false;
}
initStorage("popupcolor", "yellow");
initStorage("tonecolors", "yes");
initStorage("fontSize", "small");
zhongwenMain.config = {};
zhongwenMain.config.css = localStorage["popupcolor"];
zhongwenMain.config.tonecolors = localStorage["tonecolors"];
zhongwenMain.config.fontSize = localStorage["fontSize"]
</script>
</head>
</html>