-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
29 lines (23 loc) · 946 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
function saveOptions(e) {
e.preventDefault();
browser.storage.local.set({
addommmm_enabled: document.querySelector("#enabled").checked,
addommmm_lasagna: document.querySelector("#show_lasagna").checked
});
}
function restoreOptions() {
function setCurrentChoice(result) {
document.querySelector("#enabled").checked = result.addommmm_enabled || false;
}
function setLasagnaOption(result) {
document.querySelector("#show_lasagna").checked = result.addommmm_lasagna || false;
}
function onError(error) {
console.log(`Error: ${error}`);
}
var getting = browser.storage.local.get("addommmm_enabled");
getting.then(setCurrentChoice, onError);
browser.storage.local.get("addommmm_lasagna").then(setLasagnaOption, onError);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);