mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-29 13:50:50 +03:00
Do not show if skipDuration is 0
This commit is contained in:
@@ -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) {
|
||||||
@@ -1644,5 +1634,12 @@ function hideSponsorTime(barTimes) {
|
|||||||
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+")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user