我需要在我的chrome.declarativeContent.PageStateMatcher中添加一些Regex。
到目前为止我已经
var matcher = new chrome.declarativeContent.PageStateMatcher({
pageUrl: {
urlContains: "something.com/someRegex/something"
}
});
本质上,我希望有一个正则表达式来计算为“omething.com/4-5 char string/somithing”。
我该怎么做?这与chrome.declarativeContent.PageStateMatcher有关吗?
谢谢
发布于 2014-05-13 00:42:28
使用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() ]
}
]);
});
});
文档在这里https://developer.chrome.com/extensions/events#property-UrlFilter-hostEquals
正则表达式使用RE2语法。https://code.google.com/p/re2/wiki/Syntax
发布于 2014-03-10 19:59:32
在https://developer.chrome.com/extensions/events#property-UrlFilter-hostEquals中,它描述了urlMatches的情况。
https://stackoverflow.com/questions/22309283
复制相似问题