21 lines
585 B
TypeScript
21 lines
585 B
TypeScript
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 () { });
|
|
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 () { });
|
|
}
|
|
chrome.storage.onChanged.addListener(applyProxy);
|
|
applyProxy();
|