From d60b478b8eadf539a2657074cbd86d02221b707b Mon Sep 17 00:00:00 2001 From: Alessio Vanni Date: Sat, 2 Mar 2019 15:53:13 +0100 Subject: Change from distinct requests to blocked requests Ported from uMatrix. I agree that the number of blocked requests is more useful than the number of distinct requests. --- js/messaging.js | 2 +- js/pagestats.js | 14 +++++++------- js/tab.js | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'js') diff --git a/js/messaging.js b/js/messaging.js index 14f2005..dd2b629 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -558,7 +558,7 @@ var onMessage = function(request, sender, callback) { request.documentURI; if ( pageStore !== null ) { pageStore.hasWebWorkers = true; - pageStore.recordRequest('script', url, true); + pageStore.recordRequest('script', url, request.blocked); } if ( tabContext !== null ) { ηm.logger.writeOne(tabId, 'net', rootHostname, url, 'worker', request.blocked); diff --git a/js/pagestats.js b/js/pagestats.js index a6526e6..0a95396 100644 --- a/js/pagestats.js +++ b/js/pagestats.js @@ -206,6 +206,12 @@ PageStore.prototype = { }, recordRequest: function(type, url, block) { + if ( block !== false ) { + this.perLoadBlockedRequestCount++; + } else { + this.perLoadAllowedRequestCount++; + } + // Store distinct network requests. This is used to: // - remember which hostname/type were seen // - count the number of distinct URLs for any given @@ -230,13 +236,7 @@ PageStore.prototype = { ηm.requestStats.record(type, block); ηm.updateBadgeAsync(this.tabId); - if ( block !== false ) { - this.perLoadBlockedRequestCount++; - } else { - this.perLoadAllowedRequestCount++; - } - - this.distinctRequestCount++; + // this.distinctRequestCount++; this.mtxCountModifiedTime = Date.now(); if ( this.domains.has(hostname) === false ) { diff --git a/js/tab.js b/js/tab.js index 5629806..09bbef8 100644 --- a/js/tab.js +++ b/js/tab.js @@ -584,8 +584,8 @@ vAPI.tabs.registerListeners(); var greenSize = squareSize * Math.sqrt(pageStore.perLoadAllowedRequestCount / total); iconId = greenSize < squareSize/2 ? Math.ceil(greenSize) : Math.floor(greenSize); } - if ( this.userSettings.iconBadgeEnabled && pageStore.distinctRequestCount !== 0) { - badgeStr = this.formatCount(pageStore.distinctRequestCount); + if ( this.userSettings.iconBadgeEnabled && pageStore.perLoadBlockedRequestCount !== 0) { + badgeStr = this.formatCount(pageStore.perLoadBlockedRequestCount); } } -- cgit v1.2.3