-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsettings.js
30 lines (24 loc) · 1013 Bytes
/
settings.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
function saveOptions(e) {
e.preventDefault();
browser.storage.sync.set({
ro: document.querySelector("#ro").value,
gov: document.querySelector("#gov").value,
suc: document.querySelector("#suc").value,
jp: document.querySelector("#jp").value.toLowerCase().replace(/ /gi,"_"), //Set region, all lowercase, underscores instead of spaces
});
}
function restoreOptions() {
function setCurrentChoice(result) {
document.querySelector("#ro").value = result.ro || "Supreme Overlord";
document.querySelector("#gov").value = result.gov || "Maintain A";
document.querySelector("#suc").value = result.suc || "Task Failed Successorly";
document.querySelector("#jp").value = result.jp || "suspicious";
}
function onError(error) {
console.error(`Oh nyo: ${error}`);
}
let getting = browser.storage.sync.get();
getting.then(setCurrentChoice, onError);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);