From 48426469de28ee288e8a0b40d391f0bb62f48e8e Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 22 Apr 2018 10:01:33 -0400 Subject: [PATCH] code review of 5386558e6827 --- src/js/cosmetic-filtering.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index cf8dee775..965e39792 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -30,6 +30,12 @@ var µb = µBlock; var cosmeticSurveyingMissCountMax = parseInt(vAPI.localStorage.getItem('cosmeticSurveyingMissCountMax'), 10) || 15; +var supportsUserStylesheets = vAPI.webextFlavor.soup.has('user_stylesheet'); +// https://www.reddit.com/r/uBlockOrigin/comments/8dkvqn/116_broken_loading_custom_filters_from_my_filters/ +window.addEventListener('webextFlavor', function() { + supportsUserStylesheets = vAPI.webextFlavor.soup.has('user_stylesheet'); +}, { once: true }); + /******************************************************************************/ /* var histogram = function(label, buckets) { @@ -416,8 +422,6 @@ var FilterContainer = function() { this.netSelectorCacheCountMax = netSelectorCacheHighWaterMark; this.selectorCacheTimer = null; - this.supportsUserStylesheets = vAPI.supportsUserStylesheets; - // generic exception filters this.genericDonthideSet = new Set(); @@ -543,11 +547,6 @@ FilterContainer.prototype.freeze = function() { this.highlyGeneric.simple.str = µb.arrayFrom(this.highlyGeneric.simple.dict).join(',\n'); this.highlyGeneric.complex.str = µb.arrayFrom(this.highlyGeneric.complex.dict).join(',\n'); - // https://www.reddit.com/r/uBlockOrigin/comments/8dkvqn/116_broken_loading_custom_filters_from_my_filters/ - // Just in case. This can be removed once Firefox 60 ESR is out - // and widespread. - this.supportsUserStylesheets = vAPI.supportsUserStylesheets; - this.frozen = true; }; @@ -1201,7 +1200,7 @@ FilterContainer.prototype.retrieveGenericSelectors = function(request) { // If user stylesheets are supported in the current process, inject the // cosmetic filters now. if ( - this.supportsUserStylesheets && + supportsUserStylesheets && request.tabId !== undefined && request.frameId !== undefined ) { @@ -1416,7 +1415,7 @@ FilterContainer.prototype.retrieveDomainSelectors = function( // If user stylesheets are supported in the current process, inject the // cosmetic filters now. if ( - this.supportsUserStylesheets && + supportsUserStylesheets && request.tabId !== undefined && request.frameId !== undefined ) {