Created
July 15, 2017 14:23
-
-
Save fogrew/408448631a08840af1b8e35cdd359c2b to your computer and use it in GitHub Desktop.
Small script for calculate total time of playlist on youtube
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 total = { | |
hours: 0, | |
minutes: 0, | |
seconds: 0 | |
}; | |
document.querySelectorAll('.timestamp').forEach(time => { | |
let arTime = time.textContent.split(':'); | |
let seconds = parseFloat(arTime[1]); | |
let minutes = parseFloat(arTime[0]); | |
if(total.seconds > 59) { | |
total.minutes++; | |
total.seconds = 0; | |
} | |
total.seconds += seconds; | |
if(total.minutes > 59) { | |
total.hours++; | |
total.minutes = 0; | |
} | |
total.minutes += minutes; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment