aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2014-08-12 20:25:11 -0400
committergorhill <rhill@raymondhill.net>2014-08-12 20:25:11 -0400
commitcfafce66ca270c1234499ed0525ba09e7aa93485 (patch)
treebdfb79d7eab73ebb9c14b40b48ac5587b5abc333 /js
parent24379c1530470328bb06ffe94f885b74a4111c0c (diff)
downloaduBlock-cfafce66ca270c1234499ed0525ba09e7aa93485.zip
uBlock-cfafce66ca270c1234499ed0525ba09e7aa93485.tar.gz
uBlock-cfafce66ca270c1234499ed0525ba09e7aa93485.tar.bz2
this fixes #151
Diffstat (limited to 'js')
-rw-r--r--js/abp-hide-filters.js19
-rw-r--r--js/contentscript-end.js2
2 files changed, 16 insertions, 5 deletions
diff --git a/js/abp-hide-filters.js b/js/abp-hide-filters.js
index 25a3504..36090cd 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 3c5eaad..6956a8d 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');