Raymond Hill 2018-07-04 15:03:09 -04:00
parent 22454df64c
commit 211048396f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 10 additions and 24 deletions

View File

@ -107,10 +107,6 @@ var onMessage = function(request, sender, callback) {
case 'cosmeticFiltersInjected': case 'cosmeticFiltersInjected':
µb.cosmeticFilteringEngine.addToSelectorCache(request); µ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; break;
case 'createUserFilter': case 'createUserFilter':
@ -523,8 +519,8 @@ var onMessage = function(request, sender, callback) {
if ( µb.canInjectScriptletsNow === false ) { if ( µb.canInjectScriptletsNow === false ) {
response.scriptlets = µb.scriptletFilteringEngine.retrieve(request); response.scriptlets = µb.scriptletFilteringEngine.retrieve(request);
} }
if ( request.isRootFrame && µb.logger.isEnabled() ) { if ( response.noCosmeticFiltering !== true ) {
µb.logCosmeticFilters(tabId); µb.logCosmeticFilters(tabId, frameId);
} }
break; break;

View File

@ -506,24 +506,14 @@ var matchBucket = function(url, hostname, bucket, start) {
/******************************************************************************/ /******************************************************************************/
µBlock.logCosmeticFilters = (function() { µBlock.logCosmeticFilters = function(tabId, frameId) {
var tabIdToTimerMap = new Map(); if ( this.logger.isEnabled() ) {
vAPI.tabs.injectScript(tabId, {
var injectNow = function(tabId) { file: '/js/scriptlets/cosmetic-logger.js',
tabIdToTimerMap.delete(tabId); frameId: frameId
µ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;
})();
/******************************************************************************/ /******************************************************************************/