initial commit
This commit is contained in:
29
options/script.js
Normal file
29
options/script.js
Normal file
@@ -0,0 +1,29 @@
|
||||
async function saveOptions(e) {
|
||||
console.log("Saving options.");
|
||||
e.preventDefault();
|
||||
let bcNum = document.querySelector("#bcnum").value;
|
||||
let bDay = document.querySelector('#birthday').value;
|
||||
let autoContinue = document.querySelector('#autocontinue').checked;
|
||||
let options = {
|
||||
bcnum: bcNum,
|
||||
bday: bDay,
|
||||
autocontinue: autoContinue
|
||||
};
|
||||
await browser.storage.sync.set(options);
|
||||
console.log("Saved!");
|
||||
}
|
||||
|
||||
async function restoreOptions() {
|
||||
// We do not save user data in managed storage.
|
||||
// let res = await browser.storage.managed.get('colour');
|
||||
// document.querySelector("#managed-colour").innerText = res.colour;
|
||||
|
||||
settings = await browser.storage.sync.get();
|
||||
console.log(settings);
|
||||
document.querySelector("#bcnum").value = settings.bcnum || "";
|
||||
document.querySelector("#birthday").value = settings.bday || "";
|
||||
document.querySelector("#autocontinue").checked = settings.autocontinue || false;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', restoreOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
Reference in New Issue
Block a user