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
});
}
});
精彩评论