diff --git a/platform/chromium/vapi-usercss.pseudo.js b/platform/chromium/vapi-usercss.pseudo.js index 308811629..6d9f32e2d 100644 --- a/platform/chromium/vapi-usercss.pseudo.js +++ b/platform/chromium/vapi-usercss.pseudo.js @@ -221,11 +221,9 @@ vAPI.DOMFilterer = class { } } - addCSSRule(selectors, declarations, details) { + addCSSRule(selectors, declarations, details = {}) { if ( selectors === undefined ) { return; } - if ( details === undefined ) { details = {}; } - const selectorsStr = Array.isArray(selectors) ? selectors.join(',\n') : selectors; @@ -233,7 +231,7 @@ vAPI.DOMFilterer = class { vAPI.userStylesheet.add(selectorsStr + '\n{' + declarations + '}'); this.commit(); - if ( this.hasListeners() ) { + if ( details.silent !== true && this.hasListeners() ) { this.triggerListeners({ declarative: [ [ selectorsStr, declarations ] ] }); @@ -247,9 +245,6 @@ vAPI.DOMFilterer = class { return; } - // Do not strongly enforce internal CSS rules. - if ( details.internal ) { return; } - const isGeneric= details.lazy === true; const isSimple = details.type === 'simple'; const isComplex = details.type === 'complex'; diff --git a/platform/chromium/vapi-usercss.real.js b/platform/chromium/vapi-usercss.real.js index 333d76287..e6683f2a6 100644 --- a/platform/chromium/vapi-usercss.real.js +++ b/platform/chromium/vapi-usercss.real.js @@ -120,13 +120,12 @@ vAPI.DOMFilterer = class { } } - addCSSRule(selectors, declarations, details) { + addCSSRule(selectors, declarations, details = {}) { if ( selectors === undefined ) { return; } const selectorsStr = Array.isArray(selectors) ? selectors.join(',\n') : selectors; if ( selectorsStr.length === 0 ) { return; } - if ( details === undefined ) { details = {}; } const entry = { selectors: selectorsStr, declarations, @@ -143,7 +142,7 @@ vAPI.DOMFilterer = class { vAPI.userStylesheet.add(selectorsStr + '\n{' + declarations + '}'); } this.commit(); - if ( this.hasListeners() ) { + if ( details.silent !== true && this.hasListeners() ) { this.triggerListeners({ declarative: [ [ selectorsStr, declarations ] ] }); @@ -192,13 +191,13 @@ vAPI.DOMFilterer = class { if ( this.excludedNodeSet.has(node) ) { return; } if ( this.hideNodeAttr === undefined ) { return; } node.setAttribute(this.hideNodeAttr, ''); - if ( this.hideNodeStyleSheetInjected === false ) { - this.hideNodeStyleSheetInjected = true; - this.addCSSRule( - `[${this.hideNodeAttr}]`, - 'display:none!important;' - ); - } + if ( this.hideNodeStyleSheetInjected ) { return; } + this.hideNodeStyleSheetInjected = true; + this.addCSSRule( + `[${this.hideNodeAttr}]`, + 'display:none!important;', + { silent: true } + ); } unhideNode(node) {