-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
49 lines (43 loc) · 1.46 KB
/
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
44
45
46
47
48
49
function save_options() {
let options = {
// empty_first: document.options.empty_first.checked,
debug: document.options.debug.checked,
max_count: Number(document.options.max_count.value),
mode: document.options.mode.value,
}
if (options.max_count < 5) {
notify("修改失败,数量请大于等5")
return
}
chrome.storage.sync.set(options, function (items) {
chrome.extension.getBackgroundPage().refresh_options()
});
}
function notify(msg) {
let oldTitle = document.title; // 保存原有标题
let times = 1;
let notice = setInterval(function () {
if (times % 2) {
document.title = "通知:" + msg;
} else {
document.title = oldTitle;
if (times > 10) clearInterval(notice)
}
times++
}, 600);
}
(function () {
document.title = chrome.i18n.getMessage("Name")
chrome.storage.sync.get({
mode: 'rnu', //
max_count: 10,
debug: false,
}, function (options) {
console.log("config options", options)
// if (options.empty_first) document.options.empty_first.checked = true
if (options.debug) document.options.debug.checked = true
document.options.max_count.value = options.max_count
document.options.mode.value = options.mode
document.getElementById('save_options').onclick = save_options
})
})()