现在,我的background.js中包含以下代码,以使页面操作按钮(工具栏上的弹出按钮)只能用于特定页面:
chrome.runtime.onInstalled.addListener(function() {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostEquals: 'myWeb.com'},
})],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
但是那不是100%满足我的要求。我只想在特定页面完成加载后启用页面操作按钮。
我知道我可以在“ document_end”上运行content.js,但是我可以在此处启用/禁用页面操作按钮吗?非常感谢!