相关疑难解决方法(0)

chrome.webRequest无法正常工作?

我正在尝试在我的扩展程序中实现chrome.webRequest API,但出于某种原因,无论我做什么,它都无法正常工作.有人可以发布一个使用示例吗?还是纠正我的错误?基本上我要做的就是从响应中拦截收到的标题.

这是onBeforeSendHeaders的实现,但我也想使用OnHeadersRecieved:

var requestFilter = {
    urls: [ "<all_urls>" ]
  },
  // The 'extraInfoSpec' parameter modifies how Chrome calls your
  // listener function. 'requestHeaders' ensures that the 'details'
  // object has a key called 'requestHeaders' containing the headers,
  // and 'blocking' ensures that the object your function returns is
  // used to overwrite the headers
  extraInfoSpec = ['requestHeaders','blocking'],
  // Chrome will call your listener function in response to every
  // HTTP request
  handler = function( details ) {
    alert(details); …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome google-chrome-extension

17
推荐指数
2
解决办法
3万
查看次数

CHROME WebRequest API示例错误:"onBeforeRequest"只能用于扩展进程

我尝试测试WebRequestAPI的示例,但抛出错误:

"onBeforeRequest"只能用于扩展进程.manifest.json的:

{
    "name": "example",
   "version": "1.0",
  "permissions": [
    "experimental",
    "http://*/*", "https://*/*"
  ],
    "content_scripts": [ {
      "js": [ "foo.js" ],
      "matches": [ "http://*/*", "https://*/*" ],
      "run_at": "document_start"
   } ]
}
Run Code Online (Sandbox Code Playgroud)

foo.js 正是这个例子1

webrequest google-chrome-extension

5
推荐指数
1
解决办法
5566
查看次数