Last active
February 19, 2020 15:42
-
-
Save kamilogorek/a8196a0fdb0e4e4e9e9e10e79c53fde5 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
var elements = Array.from(document.querySelectorAll(".ytd-playlist-video-list-renderer span.ytd-thumbnail-overlay-time-status-renderer")) | |
var time = elements.map(v => { | |
const [s,m,h] = v.innerText.split(':').reverse().map(x => parseInt(x,10)); | |
return s + (m || 0) * 60 + (h || 0) * 60 * 60; | |
}) | |
var total = time.reduce((acc, v) => acc + v); | |
var h = Math.floor(total / (60 * 60)); | |
var m = Math.floor((total - (h * 60 * 60)) / 60); | |
var s = total%60; | |
console.log(`${h.toString().padStart(2, '0')}:${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment