mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 20:17:05 +03:00
Do not show if skipDuration is 0
This commit is contained in:
@@ -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+")";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user