// Restore options document.addEventListener("DOMContentLoaded", () => { browser.storage.local.get({ instance: "yewtu.be", }).then((storage) => { document.querySelector("#instance").value = storage.instance; }); }); // Save options const saveBtn = document.getElementById("saveBtn"); saveBtn.addEventListener("click", (e) => { e.preventDefault(); const instance = document.querySelector("#instance").value.trim().replace(/^https?:\/\/*|\/$/g, ''); if (!instance) return alert("Please fill out the fields!"); browser.storage.local.set({ instance, }).then(() => { saveBtn.disabled = true; saveBtn.value = "Saved!"; setTimeout(() => { saveBtn.disabled = false; saveBtn.value = "Save"; }, 3000) }); });