-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
30 lines (22 loc) · 1.1 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
async function saveOptions(e) { //formThem.optionTheme
e.preventDefault();
browser.storage.sync.set({optionFormTheme: document.querySelector("#optionFormTheme").optionTheme.value});
browser.storage.sync.set({optionThemeFull: document.querySelector("#optionFormTheme").optionThemeFull.value});
}
function restoreOptions() {
function setCurrentChoice(result) {
document.querySelector("#optionFormTheme").optionTheme.value = result.optionFormTheme || "optionThemeDefault";
}
function setCurrentChoice2(result) {
document.querySelector("#optionFormTheme").optionThemeFull.value = result.optionThemeFull || "optionFormFullFalse";
}
function onError(error) {
console.log(`Error: ${error}`);
}
var getting = browser.storage.sync.get("optionFormTheme");
getting.then(setCurrentChoice, onError);
var getting2 = browser.storage.sync.get("optionThemeFull");
getting2.then(setCurrentChoice2, onError);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);