Skip to content

Instantly share code, notes, and snippets.

@elkhadiy
Created January 14, 2019 15:41
Show Gist options
  • Save elkhadiy/77f73ee65b73ec94a143a3545e670d1a to your computer and use it in GitHub Desktop.
Save elkhadiy/77f73ee65b73ec94a143a3545e670d1a to your computer and use it in GitHub Desktop.
youtube playlist add duration
let timedelta = document.getElementById("stats").firstElementChild.cloneNode(true);
timedelta.innerText = (seconds => `${Math.floor(seconds/3600)}:${Math.floor(seconds/60) % 60}:${Math.floor(seconds) % 60}`).call(this, Array.from(document.getElementsByClassName('ytd-thumbnail-overlay-time-status-renderer')).map(x => x.innerText.split(":").map(x => parseInt(x, 10)).reduce((acc, val) => acc * 60 + val)).reduce((acc, val) => acc + val));
document.getElementById("stats").insertBefore(timedelta, document.getElementById("stats").firstElementChild.nextSibling);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment