chromium-proxy-settings/worker.ts
Mathieu Strypsteen d2738078e0
All checks were successful
Build / build (push) Successful in 43s
Make active toggle take effect immediately
2024-03-13 09:28:46 +01:00

26 lines
808 B
TypeScript

import { Storage } from './common';
async function applyProxy() {
const { host, port, bypass } = await chrome.storage.local.get(["host", "port", "bypass"]) as Storage;
const { active } = await chrome.storage.session.get("active");
if (!active) {
chrome.proxy.settings.clear({ scope: "regular" }, function () { });
await chrome.action.setBadgeText({ text: "" });
return;
}
const config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: "socks5",
host: host,
port: port
},
bypassList: bypass
}
};
chrome.proxy.settings.set({ value: config, scope: "regular" }, function () { });
await chrome.action.setBadgeText({ text: "✓" });
}
chrome.storage.onChanged.addListener(() => { void applyProxy(); });
void applyProxy();