Fixed: Undefined variable in badge text (#301)

This commit is contained in:
nobody 2021-03-14 11:03:34 +01:00
parent 0866f56ddd
commit fe1e42bf0a
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
2 changed files with 3 additions and 12 deletions

View File

@ -85,15 +85,14 @@ interceptor._handleMissingCandidate = function (requestUrl, tabIdentifier) {
let requestUrlSegments, injectionCount, missingCount; let requestUrlSegments, injectionCount, missingCount;
if (stateManager.showIconBadge === true) { if (stateManager.showIconBadge === true) {
injectionCount = Object.keys(stateManager.tabs[tabIdentifier].injections).length || 0;
if (stateManager.changeBadgeColorMissingResources === true) { if (stateManager.changeBadgeColorMissingResources === true) {
missingCount = stateManager.tabs[tabIdentifier].missing || 0; missingCount = stateManager.tabs[tabIdentifier].missing || 0;
injectionCount = Object.keys(stateManager.tabs[tabIdentifier].injections).length || 0;
if (missingCount > 0 && injectionCount === 0) { if (missingCount > 0 && injectionCount === 0) {
wrappers.setBadgeMissing(tabIdentifier, injectionCount); wrappers.setBadgeMissing(tabIdentifier, injectionCount);
} }
} else { } else {
wrappers.defaultBadge(tabIdentifier); wrappers.defaultBadge(tabIdentifier, injectionCount);
} }
} }

View File

@ -31,7 +31,7 @@ var stateManager = {};
*/ */
stateManager.registerInjection = function (tabIdentifier, injection) { stateManager.registerInjection = function (tabIdentifier, injection) {
let injectionIdentifier, registeredTab, injectionCount, missingCount, badgeText; let injectionIdentifier, registeredTab, injectionCount, missingCount;
injectionIdentifier = injection.source + injection.path + injection.version; injectionIdentifier = injection.source + injection.path + injection.version;
registeredTab = stateManager.tabs[tabIdentifier]; registeredTab = stateManager.tabs[tabIdentifier];
@ -39,20 +39,12 @@ stateManager.registerInjection = function (tabIdentifier, injection) {
injectionCount = Object.keys(registeredTab.injections).length || 0; injectionCount = Object.keys(registeredTab.injections).length || 0;
missingCount = registeredTab.missing || 0; missingCount = registeredTab.missing || 0;
badgeText = `${injectionCount}`;
if (injectionCount > 0) { if (injectionCount > 0) {
chrome.browserAction.setTitle({ chrome.browserAction.setTitle({
'tabId': tabIdentifier, 'tabId': tabIdentifier,
'title': `LocalCDN (${injectionCount})` 'title': `LocalCDN (${injectionCount})`
}); });
if (stateManager.showIconBadge === true) {
wrappers.setBadgeText({
'tabId': tabIdentifier,
'text': badgeText
});
}
} }
if (stateManager.showIconBadge === true) { if (stateManager.showIconBadge === true) {
if (missingCount > 0 && stateManager.changeBadgeColorMissingResources) { if (missingCount > 0 && stateManager.changeBadgeColorMissingResources) {