-
-
Save nvrossett/696e6d5910a8d6b7c6e639ab21baebdd to your computer and use it in GitHub Desktop.
Calcula o tempo total de uma playlist no Youtube. É só colar no console na página da playlist. Fiz esse script porque não achei o tempo total da playlist 😅.
This file contains hidden or 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
(function() { | |
var timeSeconds = 0; | |
var timestampDivList = document.querySelectorAll("#length"); | |
for(var i = 0; i < timestampDivList.length; i++) { | |
var timestampDiv = timestampDivList[i]; | |
var timeStr = timestampDiv.innerHTML; | |
if ( timeStr !== '' ){ | |
var timeParts = timeStr.split(":"); | |
var seconds = (parseInt(timeParts[0]) * 60) + parseInt(timeParts[1]); | |
timeSeconds += seconds; | |
} | |
} | |
var hours = parseInt((timeSeconds / 60) / 60); | |
var minutes = parseInt((timeSeconds / 60) % 60); | |
var seconds = parseInt((timeSeconds % 60)); | |
function plural( label, time ){ | |
return (time>1) ? label+'s' : label; | |
} | |
console.log(hours + " " + plural('Hora', hours), minutes + " " + plural('Minuto', minutes), "e", seconds + " " + plural('Segundo', seconds)); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment