diff --git a/js/abp-hide-filters.js b/js/abp-hide-filters.js index 25a350428..36090cdd6 100644 --- a/js/abp-hide-filters.js +++ b/js/abp-hide-filters.js @@ -377,10 +377,22 @@ FilterContainer.prototype.add = function(s) { var i = hostnames.length; if ( i === 0 ) { this.addGenericSelector(parsed); - } else { - while ( i-- ) { - this.addSpecificSelector(hostnames[i], parsed); + return true; + } + // https://github.com/gorhill/uBlock/issues/151 + // Negated hostname means the filter applies to all non-negated hostnames + // of same filter OR globally if there is no non-negated hostnames. + var applyGlobally = true; + var hostname; + while ( i-- ) { + hostname = hostnames[i]; + if ( hostname.charAt(0) !== '~' ) { + applyGlobally = false; } + this.addSpecificSelector(hostname, parsed); + } + if ( applyGlobally ) { + this.addGenericSelector(parsed); } return true; }; @@ -425,7 +437,6 @@ FilterContainer.prototype.addHostnameSelector = function(hostname, parsed) { // https://github.com/gorhill/uBlock/issues/145 var unhide = parsed.unhide; if ( hostname.charAt(0) === '~' ) { - this.addGenericSelector(parsed); hostname = hostname.slice(1); unhide ^= 1; } diff --git a/js/contentscript-end.js b/js/contentscript-end.js index 3c5eaad9f..6956a8dd4 100644 --- a/js/contentscript-end.js +++ b/js/contentscript-end.js @@ -317,7 +317,7 @@ var uBlockMessaging = (function(name){ var processHighHighGenerics = function(generics, out) { if ( injectedSelectors[generics] !== undefined ) { return; } - if ( document.querySelectorAll(generics) === null ) { return; } + if ( document.querySelector(generics) === null ) { return; } injectedSelectors[generics] = true; if ( out !== undefined ) { var selectors = generics.split(',\n');