I need to add some Regex inside my chrome.declarativeContent.PageStateMatcher.
So far I have
var matcher = new chrome.declarativeContent.PageStateMatcher({
pageUrl: {
urlContains: "something.com/someRegex/something"
}
});
Essentially I want to have a regular expression to evaluate to "something.com/4-5 char string/somithing".
How would I do this? Is this possible to do with chrome.declarativeContent.PageStateMatcher?
Thanks
Instead of urlContains use urlMatches
This is what I'm using for both domain fedmich.com and 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() ]
}
]);
});
});
documentation is here https://developer.chrome.com/extensions/events#property-UrlFilter-hostEquals
The regular expressions use the RE2 syntax. https://code.google.com/p/re2/wiki/Syntax
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With