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