From fe1e42bf0a7af691e5b89fb2bbdf0a57d4659917 Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 14 Mar 2021 11:03:34 +0100 Subject: [PATCH] Fixed: Undefined variable in badge text (#301) --- core/interceptor.js | 5 ++--- core/state-manager.js | 10 +--------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/core/interceptor.js b/core/interceptor.js index 8e80c4b2..2895353f 100644 --- a/core/interceptor.js +++ b/core/interceptor.js @@ -85,15 +85,14 @@ interceptor._handleMissingCandidate = function (requestUrl, tabIdentifier) { let requestUrlSegments, injectionCount, missingCount; if (stateManager.showIconBadge === true) { + injectionCount = Object.keys(stateManager.tabs[tabIdentifier].injections).length || 0; if (stateManager.changeBadgeColorMissingResources === true) { missingCount = stateManager.tabs[tabIdentifier].missing || 0; - injectionCount = Object.keys(stateManager.tabs[tabIdentifier].injections).length || 0; - if (missingCount > 0 && injectionCount === 0) { wrappers.setBadgeMissing(tabIdentifier, injectionCount); } } else { - wrappers.defaultBadge(tabIdentifier); + wrappers.defaultBadge(tabIdentifier, injectionCount); } } diff --git a/core/state-manager.js b/core/state-manager.js index 26fee5c1..f081bd16 100644 --- a/core/state-manager.js +++ b/core/state-manager.js @@ -31,7 +31,7 @@ var stateManager = {}; */ stateManager.registerInjection = function (tabIdentifier, injection) { - let injectionIdentifier, registeredTab, injectionCount, missingCount, badgeText; + let injectionIdentifier, registeredTab, injectionCount, missingCount; injectionIdentifier = injection.source + injection.path + injection.version; registeredTab = stateManager.tabs[tabIdentifier]; @@ -39,20 +39,12 @@ stateManager.registerInjection = function (tabIdentifier, injection) { injectionCount = Object.keys(registeredTab.injections).length || 0; missingCount = registeredTab.missing || 0; - badgeText = `${injectionCount}`; if (injectionCount > 0) { chrome.browserAction.setTitle({ 'tabId': tabIdentifier, 'title': `LocalCDN (${injectionCount})` }); - - if (stateManager.showIconBadge === true) { - wrappers.setBadgeText({ - 'tabId': tabIdentifier, - 'text': badgeText - }); - } } if (stateManager.showIconBadge === true) { if (missingCount > 0 && stateManager.changeBadgeColorMissingResources) {