每次Chrome请求代理用户/密码时,我都会编写一个发送代理身份验证的扩展名,但每当我打开一个需要http基本身份验证的网页时它会出现问题,它会在“等待XXXX”时停止,XXXX是我的分机名称。
我的代码如下:
var gPendingCallbacks = [];
var bkg = chrome.extension.getBackgroundPage();
chrome.webRequest.onAuthRequired.addListener(handleAuthRequest,
{urls: ["<all_urls>"]}, ["asyncBlocking"]);
function processPendingCallbacks() {
var callback = gPendingCallbacks.pop();
callback({authCredentials: {username: 'user',
password: 'pass'}});
}
function handleAuthRequest(details, callback) {
gPendingCallbacks.push(callback);
if (details.isProxy === true ){
processPendingCallbacks();
}
}
如何解决此问题?
答案 0 :(得分:1)
变化:
function handleAuthRequest(details, callback) {
gPendingCallbacks.push(callback);
if (details.isProxy === true ){
processPendingCallbacks();
}
}
为:
function handleAuthRequest(details, callback) {
gPendingCallbacks.push(callback);
processPendingCallbacks();
}