From 8f05a2f8d3fc1e5c7891bf0143d0401e3833b0a8 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 14 Dec 2018 15:25:18 -0500 Subject: [PATCH] fix https://github.com/uBlockOrigin/uBlock-issues/issues/341, and further work for https://github.com/gorhill/uBlock/issues/3683 --- src/js/contentscript.js | 1 + src/js/logger.js | 3 +++ src/js/static-ext-filtering.js | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/js/contentscript.js b/src/js/contentscript.js index 64c5d6866..896b2e54c 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -487,6 +487,7 @@ vAPI.DOMFilterer = (function() { [ ':matches-css', PSelectorMatchesCSSTask ], [ ':matches-css-after', PSelectorMatchesCSSAfterTask ], [ ':matches-css-before', PSelectorMatchesCSSBeforeTask ], + [ ':not', PSelectorIfNotTask ], [ ':xpath', PSelectorXpathTask ] ]); } diff --git a/src/js/logger.js b/src/js/logger.js index 96df0c844..d9a577546 100644 --- a/src/js/logger.js +++ b/src/js/logger.js @@ -31,6 +31,9 @@ }; LogEntry.prototype.init = function(details) { + if ( details.tstamp === undefined ) { + details.tstamp = Date.now(); + } this.details = JSON.stringify(details); }; diff --git a/src/js/static-ext-filtering.js b/src/js/static-ext-filtering.js index b54058547..abfa85c14 100644 --- a/src/js/static-ext-filtering.js +++ b/src/js/static-ext-filtering.js @@ -159,6 +159,7 @@ 'matches-css', 'matches-css-after', 'matches-css-before', + 'not', 'xpath' ].join('|'), ')\\(' @@ -209,6 +210,9 @@ }; var compileConditionalSelector = function(s) { + if ( isValidCSSSelector(s) ) { + return { selector: s, tasks: [] }; + } // https://github.com/AdguardTeam/ExtendedCss/issues/31#issuecomment-302391277 // Prepend `:scope ` if needed. if ( reNeedScope.test(s) ) { @@ -241,6 +245,7 @@ [ ':matches-css', compileCSSDeclaration ], [ ':matches-css-after', compileCSSDeclaration ], [ ':matches-css-before', compileCSSDeclaration ], + [ ':not', compileConditionalSelector ], [ ':xpath', compileXpathExpression ] ]); @@ -293,7 +298,8 @@ raw.push(':has', '(', decompile(task[1]), ')'); break; case ':if-not': - raw.push(task[0], '(', decompile(task[1]), ')'); + case ':not': + raw.push(':not', '(', decompile(task[1]), ')'); break; } }