-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
executable file
·37 lines (31 loc) · 1.2 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
// Saves options to chrome.storage
function save_options(reload) {
var t1pop = document.getElementById('cb_t1pop').checked
var t1foc = document.getElementById('cb_t1foc').checked
//var t1tab = document.getElementById('cb_t1tab').checked
chrome.storage.sync.set({
t1pop: t1pop,
t1foc: t1foc,
// t1tab: t1tab,
}, function() {
console.log('Options saved')
if (reload == true ) { chrome.runtime.reload() }
})
}
// Restores select box and checkbox state using the preferences stored in chrome.storage.
window.onload = function restore_options() {
chrome.storage.sync.get({
// default values
t1pop: true,
t1foc: true,
// t1tab: true,
}, function(items) {
document.getElementById('cb_t1pop').checked = items.t1pop
document.getElementById('cb_t1foc').checked = items.t1foc
// document.getElementById('cb_t1tab').checked = items.t1tab
console.log('Options restored')
})
}
document.getElementById('cb_t1pop').addEventListener('click', function() {save_options(true)} )
document.getElementById('cb_t1foc').addEventListener('click', function() {save_options(false)} )
//document.getElementById('cb_t1tab').addEventListener('click', function() {save_options(false)} )