我正在使用
Declarative Content API
要仅在用户使用http、http s或文件方案时显示chrome扩展的页面操作,请执行以下操作:
/**
* Show page action only only supported urls.
*/
chrome.runtime.onInstalled.addListener(() => {
const rule = {
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { schemes: ['https', 'http', 'file'] },
})
],
actions: [ new chrome.declarativeContent.ShowPageAction() ]
}
chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {
chrome.declarativeContent.onPageChanged.addRules([rule])
})
})
如果我想把这个扩展到
不是
加载到某个主机名上,特别是
chrome.google.com网站
?
这个
PageStateMatcher
支持一
urlMatcher
属性,但它基于
RE2 Regex
格式
does not seem to support a negative lookbehind
(例如排除某些词)。