Added duration override

This commit is contained in:
NDevTK
2020-06-26 19:33:19 +01:00
committed by GitHub
parent beea8181a1
commit 0ebd7f4f8d

View File

@@ -801,7 +801,8 @@ function updatePreviewBar() {
if (localSponsorTimes == null) localSponsorTimes = []; if (localSponsorTimes == null) localSponsorTimes = [];
let allSponsorTimes = localSponsorTimes.concat(sponsorTimesSubmitting); let allSponsorTimes = localSponsorTimes.concat(sponsorTimesSubmitting);
hideSponsorTime(allSponsorTimes);
//create an array of the sponsor types //create an array of the sponsor types
let types = []; let types = [];
for (let i = 0; i < localSponsorTimes.length; i++) { for (let i = 0; i < localSponsorTimes.length; i++) {
@@ -1593,3 +1594,34 @@ function updateAdFlag() {
updateVisibilityOfPlayerControlsButton(); updateVisibilityOfPlayerControlsButton();
} }
} }
function formatTime(seconds) {
if(isNaN(seconds)) return
const h = Math.floor(seconds / 3600);
const m = Math.floor((seconds % 3600) / 60);
const s = Math.round(seconds % 60);
return [
h,
m > 9 ? m : (h ? '0' + m : m || '0'),
s > 9 ? s : '0' + s
].filter(Boolean).join(':');
}
function hideSponsorTime(barTimes) {
if(!Config.config.timeWithSkips) return
let skipDuration = 0;
// Prevent dupicate UUID
let seen = [];
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];
}
let times = document.getElementsByClassName("ytp-time-display notranslate")[0].getElementsByTagName("span");
times[2].innerText = formatTime(video.duration - skipDuration);
}