From 8d53e776b8b461e336541ec8690f7227ec1e690c Mon Sep 17 00:00:00 2001 From: NDevTK <31563761+NDevTK@users.noreply.github.com> Date: Mon, 29 Jun 2020 19:35:11 +0100 Subject: [PATCH] Do not show if skipDuration is 0 --- src/content.ts | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/content.ts b/src/content.ts index f6c39de1..c01ec56e 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1612,30 +1612,20 @@ function hideSponsorTime(barTimes) { let skipDuration = 0; - // Prevent dupicate UUID - let seen = []; - + // Calculate skipDuration based from the segments in the preview bar for (let i = 0; i < barTimes.length; i++) { let time = barTimes[i]; - if(seen.includes(time.UUID)) break; - seen.push(time.UUID); skipDuration += time.segment[1] - time.segment[0]; } - if(skipDuration === 0) return - + // YouTube player time display let display = document.getElementsByClassName("ytp-time-display notranslate")[0]; if (display === undefined) return - if(Config.config.hideRealTime) { - return display.getElementsByTagName("span")[2].innerText = formatTime(video.duration - skipDuration); - } + let formatedTime = formatTime(video.duration - skipDuration); - const durationID = "durationAfterSkips"; - let duration; - - - duration = document.getElementById(durationID); + const durationID = "durationAfterSkips"; + let duration = document.getElementById(durationID); // Create span if needed if(duration === null) { @@ -1643,6 +1633,13 @@ function hideSponsorTime(barTimes) { duration.id = durationID; display.appendChild(duration); } - - duration.innerText = " ("+formatTime(video.duration - skipDuration)+")"; + + if(Config.config.hideRealTime) { + // Empty if not enabled + duration.innerText = ""; + display.getElementsByTagName("span")[2].innerText = formatedTime; + } else { + // Empty if the time is the same + duration.innerText = (skipDuration === 0) ? "" : " ("+formatedTime+")"; + } }