aboutsummaryrefslogtreecommitdiffstats
path: root/src/js
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2015-02-05 23:14:12 -0500
committergorhill <rhill@raymondhill.net>2015-02-05 23:14:12 -0500
commitd0f81f5e3baf209b56d7a99f0d39fbd3e51d6439 (patch)
tree4e9e5a5f3d5a13dda77850932cec1042aae34a0f /src/js
parent684dd00e1aaaa750b7bcec6e088d7460ba099568 (diff)
downloaduBlock-d0f81f5e3baf209b56d7a99f0d39fbd3e51d6439.zip
uBlock-d0f81f5e3baf209b56d7a99f0d39fbd3e51d6439.tar.gz
uBlock-d0f81f5e3baf209b56d7a99f0d39fbd3e51d6439.tar.bz2
this fixes #689
Diffstat (limited to 'src/js')
-rw-r--r--src/js/dynamic-net-filtering.js19
-rw-r--r--src/js/messaging.js4
-rw-r--r--src/js/pagestore.js19
-rw-r--r--src/js/ublock.js8
4 files changed, 28 insertions, 22 deletions
diff --git a/src/js/dynamic-net-filtering.js b/src/js/dynamic-net-filtering.js
index 4ed0b45..7a7c411 100644
--- a/src/js/dynamic-net-filtering.js
+++ b/src/js/dynamic-net-filtering.js
@@ -295,12 +295,24 @@ Matrix.prototype.evaluateCellZY = function(srcHostname, desHostname, type) {
/******************************************************************************/
+Matrix.prototype.mustAllowCellZY = function(srcHostname, desHostname, type) {
+ return this.evaluateCellZY(srcHostname, desHostname, type).r === 2;
+};
+
+/******************************************************************************/
+
Matrix.prototype.mustBlockOrAllow = function() {
return this.r === 1 || this.r === 2;
};
/******************************************************************************/
+Matrix.prototype.mustBlock = function() {
+ return this.r === 1;
+};
+
+/******************************************************************************/
+
Matrix.prototype.mustAbort = function() {
return this.r === 3;
};
@@ -325,13 +337,6 @@ Matrix.prototype.toFilterString = function() {
/******************************************************************************/
-Matrix.prototype.mustBlock = function(srcHostname, desHostname, type) {
- this.evaluateCellZY(srcHostname, desHostname, type);
- return this.r === 1;
-};
-
-/******************************************************************************/
-
Matrix.prototype.srcHostnameFromRule = function(rule) {
return rule.slice(0, rule.indexOf(' '));
};
diff --git a/src/js/messaging.js b/src/js/messaging.js
index 0dd46cf..f3baa58 100644
--- a/src/js/messaging.js
+++ b/src/js/messaging.js
@@ -333,7 +333,7 @@ var onMessage = function(request, sender, callback) {
switch ( request.what ) {
case 'retrieveDomainCosmeticSelectors':
- if ( pageStore && pageStore.getNetFilteringSwitch() ) {
+ if ( pageStore && pageStore.getSpecificCosmeticFilteringSwitch() ) {
response = µb.cosmeticFilteringEngine.retrieveDomainSelectors(request);
}
break;
@@ -453,7 +453,7 @@ var onMessage = function(details, sender, callback) {
switch ( details.what ) {
case 'retrieveGenericCosmeticSelectors':
- if ( pageStore && pageStore.getCosmeticFilteringSwitch() ) {
+ if ( pageStore && pageStore.getGenericCosmeticFilteringSwitch() ) {
response = µb.cosmeticFilteringEngine.retrieveGenericSelectors(details);
}
break;
diff --git a/src/js/pagestore.js b/src/js/pagestore.js
index e9ffc89..2aefdcf 100644
--- a/src/js/pagestore.js
+++ b/src/js/pagestore.js
@@ -601,9 +601,19 @@ PageStore.prototype.getNetFilteringSwitch = function() {
/******************************************************************************/
-PageStore.prototype.getCosmeticFilteringSwitch = function() {
- return this.getNetFilteringSwitch() !== false &&
- this.skipCosmeticFiltering === false;
+PageStore.prototype.getSpecificCosmeticFilteringSwitch = function() {
+ return this.getNetFilteringSwitch() &&
+ (µb.userSettings.advancedUserEnabled &&
+ µb.dynamicNetFilteringEngine.mustAllowCellZY(this.rootHostname, this.rootHostname, '*')) === false;
+};
+
+/******************************************************************************/
+
+PageStore.prototype.getGenericCosmeticFilteringSwitch = function() {
+ return this.getNetFilteringSwitch() &&
+ this.skipCosmeticFiltering === false &&
+ (µb.userSettings.advancedUserEnabled &&
+ µb.dynamicNetFilteringEngine.mustAllowCellZY(this.rootHostname, this.rootHostname, '*')) === false;
};
/******************************************************************************/
@@ -638,8 +648,7 @@ PageStore.prototype.filterRequest = function(context) {
// We evaluate dynamic filtering first, and hopefully we can skip
// evaluation of static filtering.
if ( µb.userSettings.advancedUserEnabled ) {
- var df = µb.dynamicNetFilteringEngine.clearRegisters();
- df.evaluateCellZY(context.rootHostname, context.requestHostname, context.requestType);
+ var df = µb.dynamicNetFilteringEngine.evaluateCellZY(context.rootHostname, context.requestHostname, context.requestType);
if ( df.mustBlockOrAllow() ) {
result = df.toFilterString();
}
diff --git a/src/js/ublock.js b/src/js/ublock.js
index e595cf7..c275364 100644
--- a/src/js/ublock.js
+++ b/src/js/ublock.js
@@ -154,14 +154,6 @@ var matchWhitelistDirective = function(url, hostname, directive) {
/******************************************************************************/
-// For now we will use the net whitelist
-
-µBlock.getCosmeticFilteringSwitch = function(url) {
- return this.getNetFilteringSwitch(url);
-};
-
-/******************************************************************************/
-
µBlock.stringFromWhitelist = function(whitelist) {
var r = {};
var i, bucket;