From 211048396f7337e0afee54619603b39fb37737b1 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 4 Jul 2018 15:03:09 -0400 Subject: [PATCH] fix https://github.com/uBlockOrigin/uBlock-issues/issues/102 --- src/js/messaging.js | 8 ++------ src/js/ublock.js | 26 ++++++++------------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/js/messaging.js b/src/js/messaging.js index 89ea9513d..a9359b1ef 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -107,10 +107,6 @@ var onMessage = function(request, sender, callback) { case 'cosmeticFiltersInjected': µb.cosmeticFilteringEngine.addToSelectorCache(request); - // Net-based cosmetic filters are of no interest for logging purpose. - if ( µb.logger.isEnabled() && request.type !== 'net' ) { - µb.logCosmeticFilters(tabId); - } break; case 'createUserFilter': @@ -523,8 +519,8 @@ var onMessage = function(request, sender, callback) { if ( µb.canInjectScriptletsNow === false ) { response.scriptlets = µb.scriptletFilteringEngine.retrieve(request); } - if ( request.isRootFrame && µb.logger.isEnabled() ) { - µb.logCosmeticFilters(tabId); + if ( response.noCosmeticFiltering !== true ) { + µb.logCosmeticFilters(tabId, frameId); } break; diff --git a/src/js/ublock.js b/src/js/ublock.js index d2a891eda..7d98530a9 100644 --- a/src/js/ublock.js +++ b/src/js/ublock.js @@ -506,24 +506,14 @@ var matchBucket = function(url, hostname, bucket, start) { /******************************************************************************/ -µBlock.logCosmeticFilters = (function() { - var tabIdToTimerMap = new Map(); - - var injectNow = function(tabId) { - tabIdToTimerMap.delete(tabId); - µBlock.scriptlets.injectDeep(tabId, 'cosmetic-logger'); - }; - - var injectAsync = function(tabId) { - if ( tabIdToTimerMap.has(tabId) ) { return; } - tabIdToTimerMap.set( - tabId, - vAPI.setTimeout(injectNow.bind(null, tabId), 100) - ); - }; - - return injectAsync; -})(); +µBlock.logCosmeticFilters = function(tabId, frameId) { + if ( this.logger.isEnabled() ) { + vAPI.tabs.injectScript(tabId, { + file: '/js/scriptlets/cosmetic-logger.js', + frameId: frameId + }); + } +}; /******************************************************************************/