function saveOptions(e) { e.preventDefault(); browser.storage.local.set({ url: document.querySelector("#url").value, enabled: document.querySelector("#enabled").checked }); } function restoreOptions() { function setCurrentChoice(result) { document.querySelector("#enabled").checked = result.enabled; document.querySelector("#url").value = result.url || 'https://'; } function onError(error) { console.log(`Error: ${error}`); } let getting = browser.storage.local.get(); getting.then(setCurrentChoice, onError); } document.addEventListener("DOMContentLoaded", restoreOptions); document.querySelector("form").addEventListener("submit", saveOptions);