|
|
|
@ -69,10 +69,12 @@ function setProxyForWindow(proxyConfig, windowId, callback) { |
|
|
|
|
|
|
|
// 设置认证监听器
|
|
|
|
const authHandler = function (details) { |
|
|
|
console.log("=========PROXY CONFIG===========",proxyConfig) |
|
|
|
|
|
|
|
return { |
|
|
|
authCredentials: { |
|
|
|
username: proxyConfig.username, |
|
|
|
password: proxyConfig.password |
|
|
|
username: "hwfq28m43", |
|
|
|
password: "YW29ABi6" |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -84,7 +86,13 @@ function setProxyForWindow(proxyConfig, windowId, callback) { |
|
|
|
|
|
|
|
// 添加新的监听器
|
|
|
|
chrome.webRequest.onAuthRequired.addListener( |
|
|
|
authHandler, |
|
|
|
// authHandler,
|
|
|
|
function(details,callbackFn){ |
|
|
|
console.log("onAuthRequired!", details, callbackFn); |
|
|
|
callbackFn({ |
|
|
|
authCredentials: {username: "hwfq28m43", password: "YW29ABi6"} |
|
|
|
}); |
|
|
|
}, |
|
|
|
{ urls: ["<all_urls>"] }, |
|
|
|
["asyncBlocking"] |
|
|
|
); |
|
|
|
@ -98,7 +106,16 @@ function setProxyForWindow(proxyConfig, windowId, callback) { |
|
|
|
scheme: "http", |
|
|
|
host: proxyConfig.host, |
|
|
|
port: parseInt(proxyConfig.port) |
|
|
|
}, |
|
|
|
httpsProxy:{ |
|
|
|
// 添加 HTTPS 代理规则
|
|
|
|
scheme: "http", |
|
|
|
host: proxyConfig.host, |
|
|
|
port: parseInt(proxyConfig.port), |
|
|
|
username: proxyConfig.username, |
|
|
|
password: proxyConfig.password |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
scope: "regular" |
|
|
|
@ -364,6 +381,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
// 清除代理信息
|
|
|
|
if (request.action === 'clearProxy') { |
|
|
|
try { |
|
|
|
// 清除代理设置
|
|
|
|
@ -456,6 +474,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
// 当前代理
|
|
|
|
if (request.action === 'getCurrentProxy') { |
|
|
|
try { |
|
|
|
const windowId = request.windowId; |
|
|
|
@ -495,6 +514,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
// 新窗口监听
|
|
|
|
chrome.windows.onCreated.addListener((window) => { |
|
|
|
console.log('新窗口创:', { |
|
|
|
id: window.id, |
|
|
|
@ -507,6 +527,7 @@ chrome.windows.onCreated.addListener((window) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// 新标签监听
|
|
|
|
chrome.tabs.onCreated.addListener((tab) => { |
|
|
|
console.log('新标签创建:', { |
|
|
|
id: tab.id, |
|
|
|
|