chrome.webRequest无法在Chrome 17上运行

时间:2012-02-09 03:21:11

标签: google-chrome google-chrome-extension

我在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'}。并且它不会在控制台中记录任何事情。

1 个答案:

答案 0 :(得分:7)

将权限中的"http://*"更改为"http://*/*"