mudri
mudri

Reputation: 770

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'.

Upvotes: 1

Views: 254

Answers (1)

serg
serg

Reputation: 111265

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"});
        }
    }
});

Upvotes: 1

Related Questions