-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathoptions.js
32 lines (29 loc) · 956 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
const getFromStorage = (keys) => {
if (chrome.storage) {
return new Promise((resolve, reject) => chrome.storage.local.get(keys, resolve));
} else {
return browser.storage.local.get(keys);
}
};
const setToStorage = (object) => {
if (chrome.storage) {
return new Promise((resolve, reject) => chrome.storage.local.set(object, resolve));
} else {
return browser.storage.local.set(object);
}
};
function saveOptions(e) {
e.preventDefault();
setToStorage({
keybaseBadgeOnly: document.querySelector("#keybase-badge-only").checked,
});
}
function restoreOptions() {
function setCurrentChoice({keybaseBadgeOnly}) {
console.log(keybaseBadgeOnly)
document.querySelector("#keybase-badge-only").checked = keybaseBadgeOnly || false;
}
getFromStorage('keybaseBadgeOnly').then(setCurrentChoice);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("input").onchange = saveOptions;