I am developing a Google Chrome extension, and need to use the chrome.experimental.webRequest API. I have a simple background.html, which simple includes a script file. Currently, the script looks like this:
function listenBeforeRequest(args) {
console.log(args);
};
chrome.experimental.webRequest.onBeforeRequest.addListener(listenBeforeRequest);
I have set a breakpoint on the addListener line, and it gets executed when the extension is loaded, and I get no errors. However, the listenBeforeRequest
method never gets hit. My expectation would be that the function was called before each request.
How can I make this work ?
I am using Google Chrome 16 on Windows. I have set the experimental API flag in the browser under chrome://flags
.
This is my manifest.json:
{
"name": "extension",
"version": "0.1",
"description": "...",
"background_page": "background.html",
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
},
"permissions": ["background","webRequest","experimental", "*://*"]
}
Note , I also tried chrome.webRequest
but that's undefined - even though this page claims it has been added as a stable API: http://code.google.com/chrome/extensions/trunk/webRequest.html
What am I missing ? What do I need to do to get webRequest.onBeforeRequest
event to work ?
Your permission match pattern lacks a path. Amend it to something like *://*/*
or, alternatively, use the special pattern <all_urls>
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.