Do not show if skipDuration is 0

This commit is contained in:
NDevTK
2020-06-29 19:35:11 +01:00
committed by GitHub
parent ec2950786f
commit 8d53e776b8

View File

@@ -1612,30 +1612,20 @@ function hideSponsorTime(barTimes) {
let skipDuration = 0; let skipDuration = 0;
// Prevent dupicate UUID // Calculate skipDuration based from the segments in the preview bar
let seen = [];
for (let i = 0; i < barTimes.length; i++) { for (let i = 0; i < barTimes.length; i++) {
let time = barTimes[i]; let time = barTimes[i];
if(seen.includes(time.UUID)) break;
seen.push(time.UUID);
skipDuration += time.segment[1] - time.segment[0]; skipDuration += time.segment[1] - time.segment[0];
} }
if(skipDuration === 0) return // YouTube player time display
let display = document.getElementsByClassName("ytp-time-display notranslate")[0]; let display = document.getElementsByClassName("ytp-time-display notranslate")[0];
if (display === undefined) return if (display === undefined) return
if(Config.config.hideRealTime) { let formatedTime = formatTime(video.duration - skipDuration);
return display.getElementsByTagName("span")[2].innerText = formatTime(video.duration - skipDuration);
}
const durationID = "durationAfterSkips"; const durationID = "durationAfterSkips";
let duration; let duration = document.getElementById(durationID);
duration = document.getElementById(durationID);
// Create span if needed // Create span if needed
if(duration === null) { if(duration === null) {
@@ -1643,6 +1633,13 @@ function hideSponsorTime(barTimes) {
duration.id = durationID; duration.id = durationID;
display.appendChild(duration); 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+")";
}
} }