diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index db1af9cb8..3841f7915 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -193,6 +193,15 @@ var uBlockCollapser = (function() { hostname: window.location.hostname, selectors: selectors }); + var selectorStr = selectors.join(',\n'), + style = document.createElement('style'); + // The linefeed before the style block is very important: do no remove! + style.appendChild(document.createTextNode(selectorStr + '\n{display:none !important;}')); + var parent = document.body || document.documentElement; + if ( parent ) { + parent.appendChild(style); + vAPI.styles.push(style); + } } // Renew map: I believe that even if all properties are deleted, an // object will still use more memory than a brand new one. diff --git a/src/js/contentscript-start.js b/src/js/contentscript-start.js index 9e5210dfb..1dcfbb953 100644 --- a/src/js/contentscript-start.js +++ b/src/js/contentscript-start.js @@ -94,7 +94,6 @@ var cosmeticFilters = function(details) { var text = hide.join(',\n'); hideElements(text); var style = vAPI.specificHideStyle = document.createElement('style'); - // The linefeed before the style block is very important: do not remove! style.appendChild(document.createTextNode(text + '\n{display:none !important;}')); //console.debug('µBlock> "%s" cosmetic filters: injecting %d CSS rules:', details.domain, details.hide.length, hideStyleText); var parent = document.head || document.documentElement;