d91*_*120 7 javascript regex google-chrome-extension
我需要在chrome.declarativeContent.PageStateMatcher中添加一些正则表达式.
到目前为止我有
var matcher = new chrome.declarativeContent.PageStateMatcher({
pageUrl: {
urlContains: "something.com/someRegex/something"
}
});
Run Code Online (Sandbox Code Playgroud)
基本上我想要一个正则表达式来评估"something.com/4-5 char string/somithing".
我该怎么做?这可能与chrome.declarativeContent.PageStateMatcher有关吗?
谢谢
fed*_*ich 14
而不是urlContains使用urlMatches
这就是我用于域fedmich.com和fedche.com的内容
chrome.runtime.onInstalled.addListener(function() {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([
{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { urlMatches: '(fedmich|fedche)\.com' },
})
],
actions: [ new chrome.declarativeContent.ShowPageAction() ]
}
]);
});
});
Run Code Online (Sandbox Code Playgroud)
文档在这里https://developer.chrome.com/extensions/events#property-UrlFilter-hostEquals
正则表达式使用RE2语法. https://code.google.com/p/re2/wiki/Syntax
| 归档时间: |
|
| 查看次数: |
4826 次 |
| 最近记录: |