-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
43 lines (38 loc) · 980 Bytes
/
options.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
function saveAndApply(params) {
chrome.storage.sync.set(params, function () {
chrome.runtime.sendMessage({
options: params
});
});
}
function restore() {
chrome.storage.sync.get(defaults, function(items) {
document.getElementById('toolbar_icon:' + items.toolbar_icon).checked = 'checked';
if (items.clean_url) {
document.getElementById('clean_url').checked = true;
}
});
}
document.addEventListener('DOMContentLoaded', restore);
document.getElementById('toolbar_icon:black')
.addEventListener(
'click',
saveAndApply.bind(null, { toolbar_icon: 'black' }),
false
);
document.getElementById('toolbar_icon:gray')
.addEventListener(
'click',
saveAndApply.bind(null, { toolbar_icon: 'gray' }),
false
);
document.getElementById('clean_url')
.addEventListener(
'change',
function() {
saveAndApply({
clean_url: document.getElementById('clean_url').checked
});
},
false
);