[英]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'. 我对Web开发了解不多,所以不要以为您的解决方案“太简单了就不能起作用”。
You can programatically inject javascript into pages: 您可以通过编程方式将javascript插入页面:
//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"});
}
}
});
if (specialPages[document.location.href]) {
// go away
}
else {
// do stuff
}
Something like that. 这样的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.