在Chrome扩展程序中动态部署内容脚本 [英] Dynamically deploying content scripts in Chrome extensions
本文介绍了在Chrome扩展程序中动态部署内容脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想将内容脚本部署到用户想要部署到的站点中。我有这个网站列表,我想只部署一些script.js到这些网站。
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 these 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
});
}
});
这篇关于在Chrome扩展程序中动态部署内容脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文