Make active toggle take effect immediately
All checks were successful
Build / build (push) Successful in 43s

This commit is contained in:
Mathieu Strypsteen 2024-03-13 09:28:46 +01:00
parent e06babd67c
commit d2738078e0
6 changed files with 102 additions and 92 deletions

View file

@ -1,5 +1,4 @@
export interface Storage { export interface Storage {
active: boolean,
host: string, host: string,
port: number, port: number,
bypass: string[]; bypass: string[];

View file

@ -8,9 +8,6 @@
<body> <body>
<form id="proxySettings"> <form id="proxySettings">
<label for="proxyActive">Active:</label>
<input type="checkbox" id="proxyActive">
<br>
<label for="proxyHost">Host:</label> <label for="proxyHost">Host:</label>
<input type="text" id="proxyHost"> <input type="text" id="proxyHost">
<label for="proxyPort">Port:</label> <label for="proxyPort">Port:</label>
@ -19,6 +16,9 @@
<textarea id="proxyBypass"></textarea> <textarea id="proxyBypass"></textarea>
<br> <br>
<input type="submit" value="Save"> <input type="submit" value="Save">
<br>
<label for="proxyActive">Active:</label>
<input type="checkbox" id="proxyActive" disabled="true">
</form> </form>
</body> </body>

View file

@ -1,24 +1,29 @@
import { Storage } from './common'; import { Storage } from './common';
async function saveProxy() { async function saveProxy() {
let active = (document.getElementById("proxyActive") as HTMLInputElement).checked;
const host = (document.getElementById("proxyHost") as HTMLInputElement).value; const host = (document.getElementById("proxyHost") as HTMLInputElement).value;
const port = (document.getElementById("proxyPort") as HTMLInputElement).valueAsNumber; const port = (document.getElementById("proxyPort") as HTMLInputElement).valueAsNumber;
const bypass = (document.getElementById("proxyBypass") as HTMLInputElement).value; const bypass = (document.getElementById("proxyBypass") as HTMLInputElement).value;
if (!host || !port) { if (!host || !port) {
active = false; const active = document.getElementById("proxyActive") as HTMLInputElement;
(document.getElementById("proxyActive") as HTMLInputElement).checked = false; active.disabled = true;
active.checked = false;
await toggleProxy();
} }
await chrome.storage.local.set({ active: active, host: host, port: port, bypass: bypass.split("\n") }); await chrome.storage.local.set({ host: host, port: port, bypass: bypass.split("\n") });
}
async function toggleProxy() {
await chrome.storage.session.set({ active: (document.getElementById("proxyActive") as HTMLInputElement).checked });
} }
async function fillForm() { async function fillForm() {
(document.getElementById("proxySettings") as HTMLInputElement).addEventListener("submit", () => { (document.getElementById("proxySettings") as HTMLInputElement).addEventListener("submit", () => {
void saveProxy(); void saveProxy();
}); });
const { active, host, port, bypass } = await chrome.storage.local.get(["active", "host", "port", "bypass"]) as Storage; (document.getElementById("proxyActive") as HTMLInputElement).addEventListener("click", () => {
if (active) { void toggleProxy();
(document.getElementById("proxyActive") as HTMLInputElement).checked = active; });
} const { host, port, bypass } = await chrome.storage.local.get(["host", "port", "bypass"]) as Storage;
const { active } = await chrome.storage.session.get("active");
if (host) { if (host) {
(document.getElementById("proxyHost") as HTMLInputElement).value = host; (document.getElementById("proxyHost") as HTMLInputElement).value = host;
} }
@ -28,6 +33,12 @@ async function fillForm() {
if (bypass) { if (bypass) {
(document.getElementById("proxyBypass") as HTMLInputElement).value = bypass.join("\n"); (document.getElementById("proxyBypass") as HTMLInputElement).value = bypass.join("\n");
} }
if (host && port) {
(document.getElementById("proxyActive") as HTMLInputElement).disabled = false;
if (active) {
(document.getElementById("proxyActive") as HTMLInputElement).checked = true;
}
}
} }
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
void fillForm(); void fillForm();

149
package-lock.json generated
View file

@ -1,17 +1,16 @@
{ {
"name": "chromium-proxy-settings", "name": "chromium-proxy-settings",
"version": "0.0.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "chromium-proxy-settings", "name": "chromium-proxy-settings",
"devDependencies": { "devDependencies": {
"@types/chrome": "^0.0.260", "@types/chrome": "^0.0.263",
"crx3": "^1.1.3", "crx3": "^1.1.3",
"eslint": "^8.56.0", "eslint": "^8.57.0",
"typescript": "^5.3.3", "typescript": "^5.4.2",
"typescript-eslint": "^7.0.1" "typescript-eslint": "^7.2.0"
} }
}, },
"node_modules/@aashutoshrathi/word-wrap": { "node_modules/@aashutoshrathi/word-wrap": {
@ -71,9 +70,9 @@
} }
}, },
"node_modules/@eslint/js": { "node_modules/@eslint/js": {
"version": "8.56.0", "version": "8.57.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz",
"integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0" "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -148,9 +147,9 @@
} }
}, },
"node_modules/@types/chrome": { "node_modules/@types/chrome": {
"version": "0.0.260", "version": "0.0.263",
"resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.260.tgz", "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.263.tgz",
"integrity": "sha512-lX6QpgfsZRTDpNcCJ+3vzfFnFXq9bScFRTlfhbK5oecSAjamsno+ejFTCbNtc5O/TPnVK9Tja/PyecvWQe0F2w==", "integrity": "sha512-As0vzv99ov3M6ZR7R6VzhMWFZXkPMrFrCEXXVrMN576Cm70fTkj7Df2CF+qEo170JepX50pd11cX6O4DSAtl2Q==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@types/filesystem": "*", "@types/filesystem": "*",
@ -185,22 +184,22 @@
"dev": true "dev": true
}, },
"node_modules/@types/semver": { "node_modules/@types/semver": {
"version": "7.5.7", "version": "7.5.8",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.7.tgz", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz",
"integrity": "sha512-/wdoPq1QqkSj9/QOeKkFquEuPzQbHTWAMPH/PaUMB+JuR31lXhlWXRZ52IpfDYVlDOUBvX09uBrPwxGT1hjNBg==", "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==",
"dev": true "dev": true
}, },
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "7.0.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.0.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.2.0.tgz",
"integrity": "sha512-OLvgeBv3vXlnnJGIAgCLYKjgMEU+wBGj07MQ/nxAaON+3mLzX7mJbhRYrVGiVvFiXtwFlkcBa/TtmglHy0UbzQ==", "integrity": "sha512-mdekAHOqS9UjlmyF/LSs6AIEvfceV749GFxoBAjwAv0nkevfKHWQFDMcBZWUiIC5ft6ePWivXoS36aKQ0Cy3sw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/regexpp": "^4.5.1", "@eslint-community/regexpp": "^4.5.1",
"@typescript-eslint/scope-manager": "7.0.1", "@typescript-eslint/scope-manager": "7.2.0",
"@typescript-eslint/type-utils": "7.0.1", "@typescript-eslint/type-utils": "7.2.0",
"@typescript-eslint/utils": "7.0.1", "@typescript-eslint/utils": "7.2.0",
"@typescript-eslint/visitor-keys": "7.0.1", "@typescript-eslint/visitor-keys": "7.2.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"graphemer": "^1.4.0", "graphemer": "^1.4.0",
"ignore": "^5.2.4", "ignore": "^5.2.4",
@ -226,15 +225,15 @@
} }
}, },
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "7.0.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.0.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.2.0.tgz",
"integrity": "sha512-8GcRRZNzaHxKzBPU3tKtFNing571/GwPBeCvmAUw0yBtfE2XVd0zFKJIMSWkHJcPQi0ekxjIts6L/rrZq5cxGQ==", "integrity": "sha512-5FKsVcHTk6TafQKQbuIVkXq58Fnbkd2wDL4LB7AURN7RUOu1utVP+G8+6u3ZhEroW3DF6hyo3ZEXxgKgp4KeCg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "7.0.1", "@typescript-eslint/scope-manager": "7.2.0",
"@typescript-eslint/types": "7.0.1", "@typescript-eslint/types": "7.2.0",
"@typescript-eslint/typescript-estree": "7.0.1", "@typescript-eslint/typescript-estree": "7.2.0",
"@typescript-eslint/visitor-keys": "7.0.1", "@typescript-eslint/visitor-keys": "7.2.0",
"debug": "^4.3.4" "debug": "^4.3.4"
}, },
"engines": { "engines": {
@ -254,13 +253,13 @@
} }
}, },
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "7.0.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.0.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.2.0.tgz",
"integrity": "sha512-v7/T7As10g3bcWOOPAcbnMDuvctHzCFYCG/8R4bK4iYzdFqsZTbXGln0cZNVcwQcwewsYU2BJLay8j0/4zOk4w==", "integrity": "sha512-Qh976RbQM/fYtjx9hs4XkayYujB/aPwglw2choHmf3zBjB4qOywWSdt9+KLRdHubGcoSwBnXUH2sR3hkyaERRg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "7.0.1", "@typescript-eslint/types": "7.2.0",
"@typescript-eslint/visitor-keys": "7.0.1" "@typescript-eslint/visitor-keys": "7.2.0"
}, },
"engines": { "engines": {
"node": "^16.0.0 || >=18.0.0" "node": "^16.0.0 || >=18.0.0"
@ -271,13 +270,13 @@
} }
}, },
"node_modules/@typescript-eslint/type-utils": { "node_modules/@typescript-eslint/type-utils": {
"version": "7.0.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.0.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.2.0.tgz",
"integrity": "sha512-YtT9UcstTG5Yqy4xtLiClm1ZpM/pWVGFnkAa90UfdkkZsR1eP2mR/1jbHeYp8Ay1l1JHPyGvoUYR6o3On5Nhmw==", "integrity": "sha512-xHi51adBHo9O9330J8GQYQwrKBqbIPJGZZVQTHHmy200hvkLZFWJIFtAG/7IYTWUyun6DE6w5InDReePJYJlJA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/typescript-estree": "7.0.1", "@typescript-eslint/typescript-estree": "7.2.0",
"@typescript-eslint/utils": "7.0.1", "@typescript-eslint/utils": "7.2.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"ts-api-utils": "^1.0.1" "ts-api-utils": "^1.0.1"
}, },
@ -298,9 +297,9 @@
} }
}, },
"node_modules/@typescript-eslint/types": { "node_modules/@typescript-eslint/types": {
"version": "7.0.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.0.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.2.0.tgz",
"integrity": "sha512-uJDfmirz4FHib6ENju/7cz9SdMSkeVvJDK3VcMFvf/hAShg8C74FW+06MaQPODHfDJp/z/zHfgawIJRjlu0RLg==", "integrity": "sha512-XFtUHPI/abFhm4cbCDc5Ykc8npOKBSJePY3a3s+lwumt7XWJuzP5cZcfZ610MIPHjQjNsOLlYK8ASPaNG8UiyA==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "^16.0.0 || >=18.0.0" "node": "^16.0.0 || >=18.0.0"
@ -311,13 +310,13 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree": { "node_modules/@typescript-eslint/typescript-estree": {
"version": "7.0.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.0.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.2.0.tgz",
"integrity": "sha512-SO9wHb6ph0/FN5OJxH4MiPscGah5wjOd0RRpaLvuBv9g8565Fgu0uMySFEPqwPHiQU90yzJ2FjRYKGrAhS1xig==", "integrity": "sha512-cyxS5WQQCoBwSakpMrvMXuMDEbhOo9bNHHrNcEWis6XHx6KF518tkF1wBvKIn/tpq5ZpUYK7Bdklu8qY0MsFIA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "7.0.1", "@typescript-eslint/types": "7.2.0",
"@typescript-eslint/visitor-keys": "7.0.1", "@typescript-eslint/visitor-keys": "7.2.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"globby": "^11.1.0", "globby": "^11.1.0",
"is-glob": "^4.0.3", "is-glob": "^4.0.3",
@ -363,17 +362,17 @@
} }
}, },
"node_modules/@typescript-eslint/utils": { "node_modules/@typescript-eslint/utils": {
"version": "7.0.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.0.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.2.0.tgz",
"integrity": "sha512-oe4his30JgPbnv+9Vef1h48jm0S6ft4mNwi9wj7bX10joGn07QRfqIqFHoMiajrtoU88cIhXf8ahwgrcbNLgPA==", "integrity": "sha512-YfHpnMAGb1Eekpm3XRK8hcMwGLGsnT6L+7b2XyRv6ouDuJU1tZir1GS2i0+VXRatMwSI1/UfcyPe53ADkU+IuA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.4.0", "@eslint-community/eslint-utils": "^4.4.0",
"@types/json-schema": "^7.0.12", "@types/json-schema": "^7.0.12",
"@types/semver": "^7.5.0", "@types/semver": "^7.5.0",
"@typescript-eslint/scope-manager": "7.0.1", "@typescript-eslint/scope-manager": "7.2.0",
"@typescript-eslint/types": "7.0.1", "@typescript-eslint/types": "7.2.0",
"@typescript-eslint/typescript-estree": "7.0.1", "@typescript-eslint/typescript-estree": "7.2.0",
"semver": "^7.5.4" "semver": "^7.5.4"
}, },
"engines": { "engines": {
@ -388,12 +387,12 @@
} }
}, },
"node_modules/@typescript-eslint/visitor-keys": { "node_modules/@typescript-eslint/visitor-keys": {
"version": "7.0.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.0.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.2.0.tgz",
"integrity": "sha512-hwAgrOyk++RTXrP4KzCg7zB2U0xt7RUU0ZdMSCsqF3eKUwkdXUMyTb0qdCuji7VIbcpG62kKTU9M1J1c9UpFBw==", "integrity": "sha512-c6EIQRHhcpl6+tO8EMR+kjkkV+ugUNXOmeASA1rlzkd8EPIriavpWoiEz1HR/VLhbVIdhqnV6E7JZm00cBDx2A==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "7.0.1", "@typescript-eslint/types": "7.2.0",
"eslint-visitor-keys": "^3.4.1" "eslint-visitor-keys": "^3.4.1"
}, },
"engines": { "engines": {
@ -663,16 +662,16 @@
} }
}, },
"node_modules/eslint": { "node_modules/eslint": {
"version": "8.56.0", "version": "8.57.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz",
"integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==", "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1", "@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.4", "@eslint/eslintrc": "^2.1.4",
"@eslint/js": "8.56.0", "@eslint/js": "8.57.0",
"@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/config-array": "^0.11.14",
"@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8", "@nodelib/fs.walk": "^1.2.8",
"@ungap/structured-clone": "^1.2.0", "@ungap/structured-clone": "^1.2.0",
@ -914,9 +913,9 @@
} }
}, },
"node_modules/flatted": { "node_modules/flatted": {
"version": "3.2.9", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz",
"integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==",
"dev": true "dev": true
}, },
"node_modules/fs.realpath": { "node_modules/fs.realpath": {
@ -1601,9 +1600,9 @@
} }
}, },
"node_modules/ts-api-utils": { "node_modules/ts-api-utils": {
"version": "1.2.1", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.2.1.tgz", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz",
"integrity": "sha512-RIYA36cJn2WiH9Hy77hdF9r7oEwxAtB/TS9/S4Qd90Ap4z5FSiin5zEiTL44OII1Y3IIlEvxwxFUVgrHSZ/UpA==", "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=16" "node": ">=16"
@ -1637,9 +1636,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.3.3", "version": "5.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
@ -1650,13 +1649,13 @@
} }
}, },
"node_modules/typescript-eslint": { "node_modules/typescript-eslint": {
"version": "7.0.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-7.0.1.tgz", "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-7.2.0.tgz",
"integrity": "sha512-aIquOfwHkGHrMSH57HxLT+1Qzp99YtGxEHXMRD+BXOc8fkuFBbA5BXsMYnoVXFuXOWBdXg8U2rN9Xe4p7LrPSQ==", "integrity": "sha512-VqXEBqzPxJlR8Lfg2Dywe4XpIk637kwp2sfMQ+vudNHo48TUvnlHzAyFMQknv0AdhvZFXQN0a0t9SPI3rsAYew==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/eslint-plugin": "7.0.1", "@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "7.0.1" "@typescript-eslint/parser": "7.2.0"
}, },
"engines": { "engines": {
"node": "^16.0.0 || >=18.0.0" "node": "^16.0.0 || >=18.0.0"

View file

@ -2,10 +2,10 @@
"name": "chromium-proxy-settings", "name": "chromium-proxy-settings",
"type": "module", "type": "module",
"devDependencies": { "devDependencies": {
"@types/chrome": "^0.0.260", "@types/chrome": "^0.0.263",
"crx3": "^1.1.3", "crx3": "^1.1.3",
"eslint": "^8.56.0", "eslint": "^8.57.0",
"typescript": "^5.3.3", "typescript": "^5.4.2",
"typescript-eslint": "^7.0.1" "typescript-eslint": "^7.2.0"
} }
} }

View file

@ -1,7 +1,8 @@
import { Storage } from './common'; import { Storage } from './common';
async function applyProxy() { async function applyProxy() {
const { active, host, port, bypass } = await chrome.storage.local.get(["active", "host", "port", "bypass"]) as Storage; const { host, port, bypass } = await chrome.storage.local.get(["host", "port", "bypass"]) as Storage;
const { active } = await chrome.storage.session.get("active");
if (!active) { if (!active) {
chrome.proxy.settings.clear({ scope: "regular" }, function () { }); chrome.proxy.settings.clear({ scope: "regular" }, function () { });
await chrome.action.setBadgeText({ text: "" }); await chrome.action.setBadgeText({ text: "" });