开发者

Making a Chrome extension not work on certain pages

I am creating an extension and I need to know how to make a filter, so that it is not activated on certain pages (which the user chooses). I don't know much about web开发者_开发知识库 development, so don't think that your solution is 'so easy that it mustn't work'.


You can programatically inject javascript into pages:

//in background.html
var allowedUrlList = ["http://..."];
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
    if(changeInfo.status == "complete") {
        if(allowedUrlList.indexOf(tab.url) != -1) {
            chrome.tabs.executeScript(tabId, {file: "content_script.js"});
        }
    }
});


if (specialPages[document.location.href]) {
    // go away
}
else {
    // do stuff
}

Something like that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜