如何使用chrome.webRequest阻止所有网页加载?

时间:2014-04-21 02:46:59

标签: javascript google-chrome google-chrome-extension

这是我的manifest.json

{
    "manifest_version": 2,
    "name": "Resource Blocker",
    "description": "Blocks resources loading from websites.",
    "version": "1.0",

    "background": {
        "scripts": ["main.js"]
    }, 

    "permissions": [
    "tabs", "http://*/*", "https://*/*", "webRequest", "webRequestBlocking"
    ]
}

这里是main.js

chrome.webRequest.onBeforeRequest.addListener(
        function(details) {
          return {cancel: details.url.indexOf("://www.facebook.com/") != -1};
        },
        {urls: ["<all_urls>"]},
        ["blocking"]);

这显然阻止了对facebook.com的所有请求。但是,我想阻止对所有网站的请求。我尝试用://facebook.com/<all_urls>替换://*/*无效。有谁知道解决方案?

0 个答案:

没有答案