firefox-simple-blocker
firefox-simple-blocker copied to clipboard
Add simple wildcard mode
A simple wildcard mode would allow to define items like https://*facebook.com/* by escaping all special characters except *.
Here's animplementation that you could use:
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function escapeRegExpWithWildcard(regexp) {
const escapedRegExp = escapeRegExp(regexp);
const escapedWildcard = escapeRegExp("*");
const escapedWildcardRegexp = new RegExp(escapeRegExp(escapedWildcard), "g");
return escapedRegExp.replace(escapedWildcardRegexp, ".*?");
}