开发者

Dynamically deploying content scripts in Chrome extensions

开发者 https://www.devze.com 2023-02-10 00:40 出处:网络
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

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

精彩评论

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