开发者

Dynamically deploying content scripts in Chrome extensions

I want to deploy content scripts only into sites that a user wants to deploy them to. I have this list of sites, and I want to deploy some script.js only to thes开发者_如何学编程e sites.


Something like this (in a background page):

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
    if(changeInfo.status == "complete" && isInUserList(tab.url)) {
        chrome.tabs.executeScript(tabId, {file:"script.js"}, function() {
            //script injected
        });
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜