我在chrome-extension API(chrome.webrequest)中遇到了问题。
我的manifest.json
{
"name": "tesst",
"version": "1.0",
"description": "test",
"permissions": ["webRequest","webRequestBlocking",
"http://*" ],
"options_page": "options.html",
"background_page": "background.html"
}
我的background.html
<script>
chrome.webRequest.onBeforeSendHeaders.addListener( function(info) { loldogs = [{name:'x', value: 'xx'}]; console.log("URL: " + info.url); info.requestHeaders.push.apply(info.requestHeaders,loldogs); for(var i in info.requestHeaders) { for (var key in info.requestHeaders[i]){ console.log("header "+i+" ["+key+"] "+info.requestHeaders[i][key]); } }
return {requestHeaders: info.requestHeaders}; }, {urls: ["<all_urls>"]}, ["blocking", "requestHeaders"]);
</script>
当我连接到某个网址时(例如:http://google.com),Chrome在http请求中未设置标题{name:'x',value:'xx'}。并且它不会在控制台中记录任何事情。
答案 0 :(得分:7)
将权限中的"http://*"
更改为"http://*/*"
。