20 lines
544 B
TypeScript
20 lines
544 B
TypeScript
async function apply_proxy() {
|
|
const { active, host, port } = await chrome.storage.local.get(["active", "host", "port"]);
|
|
if (!active) {
|
|
chrome.proxy.settings.clear({ scope: 'regular' }, function () { });
|
|
return;
|
|
}
|
|
const config = {
|
|
mode: "fixed_servers",
|
|
rules: {
|
|
singleProxy: {
|
|
scheme: "socks5",
|
|
host: host,
|
|
port: port
|
|
}
|
|
}
|
|
};
|
|
chrome.proxy.settings.set({ value: config, scope: 'regular' }, function () { });
|
|
}
|
|
apply_proxy();
|
|
chrome.storage.onChanged.addListener(apply_proxy);
|