-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
33 lines (28 loc) · 780 Bytes
/
options.js
File metadata and controls
33 lines (28 loc) · 780 Bytes
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
chrome.storage.local.get(null, function(options) {
if (Object.entries(options).length === 0) { // if no options yet
browser.storage.local.set({
'bg': "follow_theme",
'categories_toolbar': true
});
location.reload();
}
Inputs = document.getElementsByTagName('input');
if (options['bg'] != null) {
document.getElementById(options['bg']).checked = true;
}
for(var i = 0; i < Inputs.length; i++) {
Inputs[i].addEventListener("change", function(e) {
if(e.target.type === 'radio' && e.target.checked) { //radio button
value = e.target.value
} else {
value = e.target.checked;
}
chrome.storage.local.set({
[e.target.name]: value
});
});
if (Inputs[i].type !== 'radio') {
Inputs[i].checked = options[Inputs[i].name];
}
}
});