我想停止网站展示广告,所以我正在寻找一种创建脚本(歌剧扩展名)的方法,该脚本可以读取任何新创建的拍子的网址信息,并在包含特定域的情况下自动将其关闭
答案 0 :(得分:1)
我建议您阅读how to handle tabs in Opera addons上的本文档。它会回答您所有的问题。
基本上,您可以修改此示例代码(我从链接文档中获取并稍加修改),并根据需要进行修改:
chrome.browserAction.onClicked.addListener(function() {
chrome.tabs.query({
'currentWindow': true,
'url': pattern //<-- Your URL pattern
// This will match all tabs to the pattern we specified
}, function(tab) {
// Remove all tabs that match the URL pattern
chrome.tabs.remove(tab.map(t => t.id))
});
});