1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 07:22:28 +02:00
This commit is contained in:
gorhill 2015-02-05 23:14:12 -05:00
parent 684dd00e1a
commit d0f81f5e3b
4 changed files with 28 additions and 22 deletions

View File

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

View File

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

View File

@ -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();
}

View File

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