Reputation: 4465
I'm trying to let onBeforeRequest trigger but it doesn't trigger once.
The background page console displays an error:
Invalid value for argument 1. Expected 'object' but got 'array'
manifest.json:
{
"name": "Blocker",
"version": "1.0",
"description": "Blocks all websites",
"permissions": ["webRequest", "webRequestBlocking", "<all_urls>"],
"background": {
"scripts": ["background.js"]
},
"manifest_version": 2
}
background.js:
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
console.log("TRIGGERED")
return {cancel: true};
},
// extraInfoSpec
["blocking"]);
What am I doing wrong or am I just expecting something onBeforeRequest isn't supposed to do? For example I expect the following:
Upvotes: 0
Views: 187
Reputation: 73616
According to the documentation:
In addition to specifying a callback function, you have to specify a filter argument
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
console.log(info);
return {cancel: true};
}, {
urls: ['<all_urls>'],
},
['blocking']
);
Upvotes: 1