From 8c50b3a9aa3fec579746f756a2de06acebfa6735 Mon Sep 17 00:00:00 2001 From: Mathieu Strypsteen Date: Sun, 18 Feb 2024 12:08:41 +0100 Subject: [PATCH] Refactor --- options.ts | 4 ++-- worker.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/options.ts b/options.ts index cefc981..62c41ef 100644 --- a/options.ts +++ b/options.ts @@ -1,4 +1,4 @@ -function setProxy() { +function saveProxy() { let active = (document.getElementById("proxyActive") as HTMLInputElement).checked; const host = (document.getElementById("proxyHost") as HTMLInputElement).value; const port = (document.getElementById("proxyPort") as HTMLInputElement).value; @@ -10,7 +10,7 @@ function setProxy() { 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); + (document.getElementById("proxySettings") as HTMLInputElement).addEventListener("submit", saveProxy); const { active, host, port, bypass } = await chrome.storage.local.get(["active", "host", "port", "bypass"]); if (active) { (document.getElementById("proxyActive") as HTMLInputElement).checked = active; diff --git a/worker.ts b/worker.ts index bc111af..9beeb15 100644 --- a/worker.ts +++ b/worker.ts @@ -1,4 +1,4 @@ -async function apply_proxy() { +async function applyProxy() { const { active, host, port, bypass } = await chrome.storage.local.get(["active", "host", "port", "bypass"]); if (!active) { chrome.proxy.settings.clear({ scope: "regular" }, function () { }); @@ -17,5 +17,5 @@ async function apply_proxy() { }; chrome.proxy.settings.set({ value: config, scope: "regular" }, function () { }); } -apply_proxy(); -chrome.storage.onChanged.addListener(apply_proxy); +chrome.storage.onChanged.addListener(applyProxy); +applyProxy();