mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-26 21:21:53 +08:00
zancun
This commit is contained in:
@@ -41,8 +41,6 @@ setInterval(heartbeat, 3000)
|
|||||||
|
|
||||||
console.info("Chrome Extenstion Background is loaded")
|
console.info("Chrome Extenstion Background is loaded")
|
||||||
|
|
||||||
let proxyHost = "";
|
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
||||||
if (msg.action === "connect") {
|
if (msg.action === "connect") {
|
||||||
console.info("Start to connect websocket")
|
console.info("Start to connect websocket")
|
||||||
@@ -65,15 +63,17 @@ chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
|||||||
},
|
},
|
||||||
scope: 'regular',
|
scope: 'regular',
|
||||||
})
|
})
|
||||||
proxyHost = `${msg.scheme}://${msg.host}:${msg.port}`
|
|
||||||
} else if (msg.action === 'clearproxy') {
|
} else if (msg.action === 'clearproxy') {
|
||||||
chrome.proxy.settings.clear({})
|
chrome.proxy.settings.clear({})
|
||||||
proxyHost = ""
|
|
||||||
} else if (msg.action === 'proxystatus') {
|
} else if (msg.action === 'proxystatus') {
|
||||||
if (proxyHost !== '') {
|
chrome.proxy.settings.get({}, function (details) {
|
||||||
chrome.runtime.sendMessage({enable: !!proxyHost, proxy: proxyHost})
|
if (details.value && details.value.mode === "fixed_servers") {
|
||||||
|
let proxyConfig = details.value.rules.singleProxy;
|
||||||
|
chrome.runtime.sendMessage({ enable: true, proxy: `${proxyConfig.scheme}://${proxyConfig.host}:${proxyConfig.port}` })
|
||||||
} else {
|
} else {
|
||||||
chrome.runtime.sendMessage({ enable: false, proxy: "" })
|
chrome.runtime.sendMessage({ enable: false, proxy: "" })
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user