diff --git a/src/js/codemirror/ubo-static-filtering.js b/src/js/codemirror/ubo-static-filtering.js index 70be0dc7f4435..d7a0e570a33c7 100644 --- a/src/js/codemirror/ubo-static-filtering.js +++ b/src/js/codemirror/ubo-static-filtering.js @@ -417,9 +417,8 @@ const initHints = function() { const parser = new StaticFilteringParser(); const proceduralOperatorNames = new Map( - Array.from(parser.proceduralOperatorTokens).filter(item => { - return (item[1] & 0b01) !== 0; - }) + Array.from(parser.proceduralOperatorTokens) + .filter(item => (item[1] & 0b01) !== 0) ); const excludedHints = new Set([ 'genericblock', diff --git a/src/js/contentscript-extra.js b/src/js/contentscript-extra.js index 88afab0fc8d63..22721cd54d0be 100644 --- a/src/js/contentscript-extra.js +++ b/src/js/contentscript-extra.js @@ -102,6 +102,21 @@ const PSelectorMinTextLengthTask = class { } }; +const PSelectorMatchesPathTask = class { + constructor(task) { + let arg0 = task[1], arg1; + if ( Array.isArray(task[1]) ) { + arg1 = arg0[1]; arg0 = arg0[0]; + } + this.needle = new RegExp(arg0, arg1); + } + transpose(node, output) { + if ( this.needle.test(self.location.pathname) ) { + output.push(node); + } + } +}; + // https://github.com/AdguardTeam/ExtendedCss/issues/31#issuecomment-302391277 // Prepend `:scope ` if needed. const PSelectorSpathTask = class { @@ -232,6 +247,7 @@ const PSelector = class { [ ':matches-css', PSelectorMatchesCSSTask ], [ ':matches-css-after', PSelectorMatchesCSSAfterTask ], [ ':matches-css-before', PSelectorMatchesCSSBeforeTask ], + [ ':matches-path', PSelectorMatchesPathTask ], [ ':min-text-length', PSelectorMinTextLengthTask ], [ ':not', PSelectorIfNotTask ], [ ':nth-ancestor', PSelectorUpwardTask ], diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index 933567fe268fa..8722a299ec3fe 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -1618,6 +1618,7 @@ Parser.prototype.SelectorCompiler = class { case ':spath': raw.push(task[1]); break; + case ':matches-path': case ':min-text-length': case ':upward': case ':watch-attr': @@ -1793,6 +1794,8 @@ Parser.prototype.SelectorCompiler = class { return this.compileCSSDeclaration(args); case ':matches-css-before': return this.compileCSSDeclaration(args); + case ':matches-path': + return this.compileText(args); case ':min-text-length': return this.compileInteger(args); case ':not': @@ -1826,6 +1829,7 @@ Parser.prototype.proceduralOperatorTokens = new Map([ [ 'matches-css', 0b11 ], [ 'matches-css-after', 0b11 ], [ 'matches-css-before', 0b11 ], + [ 'matches-path', 0b01 ], [ 'min-text-length', 0b01 ], [ 'not', 0b01 ], [ 'nth-ancestor', 0b00 ],