From eac3025f8c65681cf84c7274ec31371bbdf86c35 Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 8 Aug 2020 07:30:04 +0200 Subject: [PATCH] Integrated internal statistics (#74) --- core/state-manager.js | 12 ++++++++++++ pages/background/background.html | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core/state-manager.js b/core/state-manager.js index bec18593..574a23e1 100644 --- a/core/state-manager.js +++ b/core/state-manager.js @@ -71,6 +71,9 @@ stateManager.registerInjection = function (tabIdentifier, injection) { [Setting.AMOUNT_INJECTED]: ++interceptor.amountInjected }); } + if (stateManager.internalStatistics) { + stats.setStats(injection); + } }; stateManager.addDomainToWhitelist = function (domain) { @@ -215,6 +218,9 @@ stateManager._handleStorageChanged = function (changes) { if (Setting.SELECTED_ICON in changes) { stateManager.selectedIcon = changes.selectedIcon.newValue; } + if (Setting.INTERNAL_STATISTICS in changes) { + stateManager.internalStatistics = changes.internalStatistics.newValue; + } }; stateManager._clearBadgeText = function (tabIdentifier) { @@ -267,6 +273,7 @@ stateManager.tabs = {}; stateManager.getInvertOption = false; stateManager.validHosts = []; stateManager.selectedIcon = 'Default'; +stateManager.internalStatistics = false; for (let mapping in mappings) { @@ -290,6 +297,11 @@ chrome.storage.sync.get([Setting.SHOW_ICON_BADGE, Setting.SELECTED_ICON], functi stateManager.selectedIcon = items.selectedIcon; }); +chrome.storage.local.get([Setting.INTERNAL_STATISTICS], function (items) { + stateManager.internalStatistics = items.internalStatistics; +}); + + /** * Event Handlers */ diff --git a/pages/background/background.html b/pages/background/background.html index 5ab3537b..86ba6d17 100644 --- a/pages/background/background.html +++ b/pages/background/background.html @@ -5,9 +5,12 @@ + + - + +