From 6fc7f96a4866458953f2fbae5239916aada78ce0 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 19 Dec 2014 14:00:46 -0500 Subject: [PATCH] this fixes #423 --- src/js/contentscript-end.js | 5 +++++ src/js/contentscript-start.js | 8 +++++++- src/js/cosmetic-filtering.js | 6 ++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 25c620053..1d8cf7f68 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -42,6 +42,11 @@ var messager = vAPI.messaging.channel('contentscript-end.js'); // ABP cosmetic filters (function() { + if ( vAPI.skipCosmeticFiltering ) { + // console.debug('Abort cosmetic filtering'); + return; + } + var queriedSelectors = {}; var injectedSelectors = vAPI.hideCosmeticFilters || {}; var classSelectors = null; diff --git a/src/js/contentscript-start.js b/src/js/contentscript-start.js index aed3f4f53..a85634836 100644 --- a/src/js/contentscript-start.js +++ b/src/js/contentscript-start.js @@ -34,11 +34,16 @@ /******************************************************************************/ -// because Safari +// Because Safari if ( vAPI.canExecuteContentScript() !== true ) { return; } +// Because in case +if ( !vAPI ) { + return; +} + /******************************************************************************/ var localMessager = vAPI.messaging.channel('contentscript-start.js'); @@ -116,6 +121,7 @@ var netFilters = function(details) { }; var filteringHandler = function(details) { + vAPI.skipCosmeticFiltering = !details || details.skipCosmeticFiltering; if ( details ) { if ( details.cosmeticHide.length !== 0 || details.cosmeticDonthide.length !== 0 ) { cosmeticFilters(details); diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index 1aac13e37..5435dd519 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -969,7 +969,7 @@ FilterContainer.prototype.pruneSelectorCache = function() { /******************************************************************************/ FilterContainer.prototype.retrieveGenericSelectors = function(request) { - if ( µb.userSettings.parseAllABPHideFilters !== true ) { + if ( this.acceptedCount !== 0 ) { return; } if ( !request.selectors ) { @@ -1031,9 +1031,6 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) { /******************************************************************************/ FilterContainer.prototype.retrieveDomainSelectors = function(request) { - if ( µb.userSettings.parseAllABPHideFilters !== true ) { - return; - } if ( !request.locationURL ) { return; } @@ -1047,6 +1044,7 @@ FilterContainer.prototype.retrieveDomainSelectors = function(request) { var r = { domain: domain, entity: pos === -1 ? domain : domain.slice(0, pos - domain.length), + skipCosmeticFiltering: this.acceptedCount === 0, cosmeticHide: [], cosmeticDonthide: [], netHide: [],