![](/img/trans.png)
[英]Chrome extension intercept ajax requests to specific endpoints to modify form data
[英]How do I intercept and modify HTTP Auth requests from a Chrome extension?
根據文檔,我編寫了以下代碼作為后台腳本:
chrome.webRequest.onAuthRequired.addListener(
function (details, callback) {
console.log('onAuthRequired', details);
callback({
authCredentials: {username: "alpha", password: "beta"}
});
},
{urls: ['<all_urls>']},
['asyncBlocking']
);
chrome.webRequest.onBeforeRequest.addListener(
function(details, callback) {
console.log('onBeforeRequest', details);
},
{urls: ['<all_urls>']}
);
onBeforeRequest
回調有效,但onAuthRequired
回調無效。 我似乎並沒有像預期的那樣將'onBeforeRequest'
打印到控制台。 什么東西少了?
我的意圖僅僅是為特定域自動提供身份驗證憑據。 一個可行的例子就可以作為答案。
您的代碼看起來不錯,但你需要使用webRequestBlocking
的權限除了普通webRequest
許可。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.