From 21f3dc83ec1e3071649fb8505e0f505605980fa1 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sat, 24 Sep 2016 14:42:31 -0400 Subject: [PATCH] code review re. #1912 --- src/js/contentscript.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/js/contentscript.js b/src/js/contentscript.js index f7c62bd7d..6adb77b6b 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -296,6 +296,7 @@ var domFilterer = { enabled: true, hiddenId: vAPI.randomToken(), hiddenNodeCount: 0, + hiddenNodeEnforcer: false, loggerEnabled: undefined, styleTags: [], @@ -434,10 +435,6 @@ var domFilterer = { this.job1._0.length = 0; } - if ( styleText !== '' ) { - this.addStyleTag(styleText); - } - // Simple selectors: incremental. // Stock job 2 = simple css selectors/hide @@ -472,14 +469,19 @@ var domFilterer = { // user styles, this allows uBO to win. var commitHit = this.hiddenNodeCount !== beforeHiddenNodeCount; if ( commitHit ) { - if ( beforeHiddenNodeCount === 0 ) { - this.addStyleTag(':root *[' + this.hiddenId + '][hidden] { display: none !important; }'); + if ( this.hiddenNodeEnforcer === false ) { + styleText += '\n:root *[' + this.hiddenId + '][hidden] { display: none !important; }'; + this.hiddenNodeEnforcer = true; } this.addedNodesHandlerMissCount = 0; } else { this.addedNodesHandlerMissCount += 1; } + if ( styleText !== '' ) { + this.addStyleTag(styleText); + } + // Un-hide nodes previously hidden. i = complexSelectorsOldResultSet.size; if ( i !== 0 ) {