-
Notifications
You must be signed in to change notification settings - Fork 13
/
options.js
36 lines (29 loc) · 1.08 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
36
// Saves options to storage.
function saveOptions() {
const query = {
imageType: document.getElementById("image").value,
animated: document.getElementById("animated").checked
};
function callback() {
// Update status to let user know options were saved.
const status = document.getElementById("status");
status.textContent = "Options saved.";
setTimeout(() => {
status.textContent = "";
}, 2000);
}
browser.storage.sync.set(query).then(callback);
}
// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
function restoreOptions() {
const query = { imageType: "D531106", animated: false };
function callback(options) {
document.getElementById("image").value = options.imageType;
document.getElementById("animated").checked = options.animated;
}
browser.storage.sync.get(query).then(callback);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.getElementById("save").addEventListener("click", saveOptions);
document.getElementById("year").innerText = new Date().getFullYear();