diff options
author | Ajay Ramachandran <[email protected]> | 2021-07-06 01:35:39 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-07-06 01:35:39 -0400 |
commit | b06694533136e8609e251280ddca6c66299fd4dd (patch) | |
tree | 676c9f6e4dfcdfc25007ae462f20a992e3a505b9 | |
parent | 584cfd4ff8964a0747e3fb047c10decd6fef3e00 (diff) | |
download | SponsorBlock-b06694533136e8609e251280ddca6c66299fd4dd.tar.gz SponsorBlock-b06694533136e8609e251280ddca6c66299fd4dd.zip |
Use segment count from the API
-rw-r--r-- | src/popup.ts | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/popup.ts b/src/popup.ts index e1dac07b..7cae5c92 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -168,34 +168,30 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> { PageElements.usernameValue.innerText = userInfo.userName; - //get the amount of times this user has contributed and display it to thank them - if (Config.config.sponsorTimesContributed != undefined) { - PageElements.sponsorTimesContributionsDisplay.innerText = Config.config.sponsorTimesContributed.toLocaleString(); - PageElements.sponsorTimesContributionsContainer.classList.remove("hidden"); - - //get the userID - const viewCount = userInfo.viewCount; - if (viewCount != 0) { - if (viewCount > 1) { - PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segments"); - } else { - PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segment"); - } + PageElements.sponsorTimesContributionsDisplay.innerText = userInfo.segmentCount.toLocaleString(); + PageElements.sponsorTimesContributionsContainer.classList.remove("hidden"); - PageElements.sponsorTimesViewsDisplay.innerText = viewCount.toLocaleString(); - PageElements.sponsorTimesViewsContainer.style.display = "unset"; + const viewCount = userInfo.viewCount; + if (viewCount != 0) { + if (viewCount > 1) { + PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segments"); + } else { + PageElements.sponsorTimesViewsDisplayEndWord.innerText = chrome.i18n.getMessage("Segment"); } - const minutesSaved = userInfo.minutesSaved; - if (minutesSaved != 0) { - if (minutesSaved != 1) { - PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower"); - } else { - PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower"); - } + PageElements.sponsorTimesViewsDisplay.innerText = viewCount.toLocaleString(); + PageElements.sponsorTimesViewsContainer.style.display = "unset"; + } - PageElements.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved); + const minutesSaved = userInfo.minutesSaved; + if (minutesSaved != 0) { + if (minutesSaved != 1) { + PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower"); + } else { + PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minLower"); } + + PageElements.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved); } } |