-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.js
28 lines (26 loc) · 912 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
function saveOptions(e) {
browser.storage.sync.set({
hash: document.querySelector("#hash").checked,
notifications: document.querySelector("#notifications").checked,
useCustomOptions: true,
});
e.preventDefault();
}
function restoreOptions() {
const gettingItem = browser.storage.sync.get();
gettingItem.then((res) => {
if (res.useCustomOptions) {
document.querySelector("#hash").checked = res.hash;
document.querySelector("#notifications").checked = res.notifications;
} else {
// Add default options
browser.storage.sync.set({
hash: document.querySelector("#hash").checked,
notifications: document.querySelector("#notifications").checked,
useCustomOptions: true,
});
}
});
}
document.addEventListener('DOMContentLoaded', restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);