Created
September 14, 2018 14:14
-
-
Save williamtguerra/de86a106c06bf84eaf69fbaa6c4750a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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