문제

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?

도움이 되었습니까?

해결책

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").

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top