function setProxy() { let active = (document.getElementById("proxyActive") as HTMLInputElement).checked; const host = (document.getElementById("proxyHost") as HTMLInputElement).value; const port = (document.getElementById("proxyPort") as HTMLInputElement).value; const bypass = (document.getElementById("proxyBypass") as HTMLInputElement).value; if (!host || !port) { active = false; (document.getElementById("proxyActive") as HTMLInputElement).checked = false; } chrome.storage.local.set({ active: active, host: host, port: Number(port), bypass: bypass.split("\n") }); } window.addEventListener("DOMContentLoaded", async () => { (document.getElementById("proxySettings") as HTMLInputElement).addEventListener("submit", setProxy); const { active, host, port, bypass } = await chrome.storage.local.get(["active", "host", "port", "bypass"]); if (active) { (document.getElementById("proxyActive") as HTMLInputElement).checked = active; } if (host) { (document.getElementById("proxyHost") as HTMLInputElement).value = host; } if (port) { (document.getElementById("proxyPort") as HTMLInputElement).value = port; } if (bypass) { (document.getElementById("proxyBypass") as HTMLInputElement).value = bypass.join("\n"); } });