Monday, June 3, 2024
51
rated 0 times [  55] [ 4]  / answers: 1 / hits: 26605  / 9 Years ago, tue, march 17, 2015, 12:00:00

I am trying to create an extension to analyse requests made on the chrome browser but I can't put it work. The alert never fires.



manifest.json



{
name: Test,
description: Test,
version: 1.0,
manifest_version: 2,
permissions: [background, tabs, webRequest, webRequestBlocking, *://*/*],
background: {
scripts: [background.js],
persistent: true
}
}


background.js



var callback = function(details) {
alert(hello);
};
var filter = { *://*/* };
var opt_extraInfoSpec = [];

chrome.webRequest.onBeforeRequest.addListener(
callback, filter, opt_extraInfoSpec);


Why is it my alert not firing?


More From » google-chrome

 Answers
6

Your filter is the wrong format - it's not a valid object at all. Addtionally it needs to contain at least the 'url' property. If you wan't all URL's, use this:



var filter = {urls: [<all_urls>]};


Check out this for exact details on the format for the filter: https://developer.chrome.com/extensions/webRequest#type-RequestFilter


[#67403] Monday, March 16, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
danae

Total Points: 26
Total Questions: 97
Total Answers: 112

Location: Oman
Member since Wed, Apr 12, 2023
1 Year ago
;