Skip to content

Instantly share code, notes, and snippets.

@fogrew
Created July 15, 2017 14:23
Show Gist options
  • Save fogrew/408448631a08840af1b8e35cdd359c2b to your computer and use it in GitHub Desktop.
Save fogrew/408448631a08840af1b8e35cdd359c2b to your computer and use it in GitHub Desktop.
Small script for calculate total time of playlist on youtube
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