This commit is contained in:
gorhill 2014-08-12 20:25:11 -04:00
parent 24379c1530
commit cfafce66ca
2 changed files with 16 additions and 5 deletions

View File

@ -377,10 +377,22 @@ FilterContainer.prototype.add = function(s) {
var i = hostnames.length; var i = hostnames.length;
if ( i === 0 ) { if ( i === 0 ) {
this.addGenericSelector(parsed); this.addGenericSelector(parsed);
} else { return true;
while ( i-- ) {
this.addSpecificSelector(hostnames[i], parsed);
} }
// 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; return true;
}; };
@ -425,7 +437,6 @@ FilterContainer.prototype.addHostnameSelector = function(hostname, parsed) {
// https://github.com/gorhill/uBlock/issues/145 // https://github.com/gorhill/uBlock/issues/145
var unhide = parsed.unhide; var unhide = parsed.unhide;
if ( hostname.charAt(0) === '~' ) { if ( hostname.charAt(0) === '~' ) {
this.addGenericSelector(parsed);
hostname = hostname.slice(1); hostname = hostname.slice(1);
unhide ^= 1; unhide ^= 1;
} }

View File

@ -317,7 +317,7 @@ var uBlockMessaging = (function(name){
var processHighHighGenerics = function(generics, out) { var processHighHighGenerics = function(generics, out) {
if ( injectedSelectors[generics] !== undefined ) { return; } if ( injectedSelectors[generics] !== undefined ) { return; }
if ( document.querySelectorAll(generics) === null ) { return; } if ( document.querySelector(generics) === null ) { return; }
injectedSelectors[generics] = true; injectedSelectors[generics] = true;
if ( out !== undefined ) { if ( out !== undefined ) {
var selectors = generics.split(',\n'); var selectors = generics.split(',\n');