Skip to content

Instantly share code, notes, and snippets.

@williamtguerra
Created September 14, 2018 14:14
Show Gist options
  • Save williamtguerra/de86a106c06bf84eaf69fbaa6c4750a7 to your computer and use it in GitHub Desktop.
Save williamtguerra/de86a106c06bf84eaf69fbaa6c4750a7 to your computer and use it in GitHub Desktop.
window.yt = {h: 0, m: 0, s: 0}
document.querySelectorAll('.ytd-playlist-video-list-renderer .ytd-thumbnail-overlay-time-status-renderer').forEach((n) => {
const split = n.innerText.split(':').map((i) => parseInt(i));
const s = split[split.length-1];
const m = split[split.length-2];
const h = split.length > 2 ? split[0] : 0;
window.yt.h += h;
window.yt.m += m;
window.yt.s += s;
if (window.yt.s > 59) {
window.yt.m ++;
window.yt.s -= 60;
}
if (window.yt.m > 59) {
window.yt.h ++;
window.yt.m -= 60;
}
});
console.log(`Total duration: ${window.yt.h}hrs ${window.yt.m}min ${window.yt.s}sec`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment