1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00
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;
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;
}

View File

@ -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');