Browse Source

调整验证函数

torsen
453530270@qq.com 1 year ago
parent
commit
73a7b393e5
  1. 27
      douyin/background.js

27
douyin/background.js

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

Loading…
Cancel
Save