Rea*_*eal 5 javascript google-chrome-extension
chrome 是否有一个 api 可以禁用(从而灰显)某些 url 上的 chrome 扩展,或者我只需要有一个 if 语句来检查 url 并相应地切换图标?
您可以使用,它允许您根据网页的 URL 及其内容匹配的 CSS 选择器chrome.declarativeContent来显示页面操作。
您可以通过像and这样的构造函数创建条件(是的,您可以使用正则表达式)和操作( ) 。详细示例在api 文档中列出。ShowPageAction SetIconnew chrome.declarativeContent.PageStateMatchernew chrome.declarativeContent.ShowPageAction()
var rule2 = {
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostEquals: 'www.google.com', schemes: ['https'] },
css: ["input[type='password']"]
}),
new chrome.declarativeContent.PageStateMatcher({
css: ["video"]
})
],
actions: [ new chrome.declarativeContent.ShowPageAction() ]
};
chrome.runtime.onInstalled.addListener(function(details) {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([rule2]);
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3224 次 |
| 最近记录: |