diff --git a/js/contentscript-end.js b/js/contentscript-end.js index 65bd0d6df..2fabb45b1 100644 --- a/js/contentscript-end.js +++ b/js/contentscript-end.js @@ -135,6 +135,20 @@ var CosmeticFiltering = function() { }; CosmeticFiltering.prototype.onDOMContentLoaded = function() { + // https://github.com/gorhill/uBlock/issues/14 + // Treat any existing domain-specific exception selectors as if they had + // been injected already. + var style = document.getElementById('uBlock1ae7a5f130fc79b4fdb8a4272d9426b5'); + var exceptions = style && style.getAttribute('uBlock1ae7a5f130fc79b4fdb8a4272d9426b5'); + if ( exceptions ) { + exceptions = decodeURIComponent(exceptions).split('\n'); + var i = exceptions.length; + while ( i-- ) { + this.injectedSelectors[exceptions[i]] = true; + } + } + + // TODO: evaluate merging into a single loop this.classesFromNodeList(document.querySelectorAll('*[class]')); this.idsFromNodeList(document.querySelectorAll('*[id]')); this.retrieveGenericSelectors(); @@ -218,11 +232,10 @@ CosmeticFiltering.prototype.filterUnfiltered = function(inSelectors, outSelector }; CosmeticFiltering.prototype.reduce = function(selectors, dict) { - var first = dict.µb === undefined; var i = selectors.length, selector, end; while ( i-- ) { selector = selectors[i]; - if ( first || !dict[selector] ) { + if ( !dict[selector] ) { if ( end !== undefined ) { selectors.splice(i+1, end-i); end = undefined; @@ -235,7 +248,6 @@ CosmeticFiltering.prototype.reduce = function(selectors, dict) { if ( end !== undefined ) { selectors.splice(0, end+1); } - dict.µb = true; }; CosmeticFiltering.prototype.classesFromNodeList = function(nodes) { diff --git a/js/contentscript-start.js b/js/contentscript-start.js index b50503ff5..0296f7a5a 100644 --- a/js/contentscript-start.js +++ b/js/contentscript-start.js @@ -155,6 +155,16 @@ var domainCosmeticFilteringHandler = function(selectors) { if ( styleText.length > 0 ) { var style = document.createElement('style'); style.appendChild(document.createTextNode(styleText.join('\n'))); + if ( selectors.donthide.length > 0 ) { + style.setAttribute( + 'id', + 'uBlock1ae7a5f130fc79b4fdb8a4272d9426b5' + ); + style.setAttribute( + 'uBlock1ae7a5f130fc79b4fdb8a4272d9426b5', + encodeURIComponent(selectors.donthide.join('\n')) + ); + } var parent = document.head || document.documentElement; if ( parent ) { parent.appendChild(style); diff --git a/js/traffic.js b/js/traffic.js index f4d95ae30..3de778414 100644 --- a/js/traffic.js +++ b/js/traffic.js @@ -101,7 +101,7 @@ var onBeforeRequestHandler = function(details) { } // Blocked - // console.debug('onBeforeRequestHandler()> BLOCK "%s": %o', details.url, details); + //console.debug('µBlock> onBeforeRequestHandler()> BLOCK "%s" because "%s"', details.url, reason); // Redirect to noop versions whenever possible. var redirectPath = typeToRedirectPathMap[requestType]; diff --git a/manifest.json b/manifest.json index 03711a901..243a66249 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_extName__", "short_name": "µBlock", - "version": "0.1.0.7", + "version": "0.1.0.8", "description": "__MSG_extShortDesc__", "icons": { "16": "img/icon_16.png",