Frage

This code doesn't work:

chrome.webRequest.onBeforeRequest.addListener(function(details){

    console.log(details);

},{urls:["<all_urls>"]},['blocking']);

This code does work:

chrome.webRequest.onBeforeRequest.addListener(function(details){

    console.log(details);

},{urls:["<all_urls>"]});

The question - Why the first code won't work?

War es hilfreich?

Lösung

The only difference between your first and second code snippet is the "blocking" extraInfoSpec.
This suggests that you have not declared the required webRequestBlocking permission in manifest.json. If you want to use "blocking", then you have to add it to manifest.json, like this:

{
    ...
    "permissions": [
        "webRequest",
        "webRequestBlocking",
        "webRequest"
    ],
    ...
}

This is a bug, and it has been reported at https://code.google.com/p/chromium/issues/detail?id=311511 ("Missing webRequestBlocking permission gives no warning to developers").

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top