-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
35 lines (29 loc) · 1.05 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
31
32
33
34
35
function saveOptions(e) {
e.preventDefault();
browser.storage.sync.set({
maxExpiryDays: document.querySelector("#maxExpiryDays").value
});
browser.runtime.reload();
}
function restoreOptions() {
function setCurrentChoice(result) {
document.querySelector("#maxExpiryDays").value = result.maxExpiryDays || "15";
document.querySelector("#cc").value = result.maxExpiryDays || "15";
}
function onError(error) {
console.log(`Error: ${error}`);
}
let getting = browser.storage.sync.get("maxExpiryDays");
getting.then(setCurrentChoice, onError);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);
let myinput = document.querySelector("#maxExpiryDays");
myinput.addEventListener("input", () => {
document.getElementById("cc").value = myinput.value;
});
let cc = document.querySelector("#cc");
cc.addEventListener("input", () => {
document.getElementById("maxExpiryDays").value = cc.value;
});
document.addEventListener("DOMContentLoaded", restoreOptions);