-
-
Save joismar/4fe344d149e5a2bd6d1fb18e6092da3f 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. Update para a nova interface do 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
(function() { | |
if (document.getElementsByClassName('ytd-playlist-video-list-renderer') != "undefined") { | |
var playlist = document.querySelector("ytd-playlist-video-list-renderer"); | |
} | |
else { | |
var playlist = document.querySelector("ytd-playlist-panel-renderer"); | |
} | |
var timeSeconds = 0, | |
timesContainer = playlist.querySelectorAll("ytd-thumbnail-overlay-time-status-renderer"); | |
for(var i = 0; i < timesContainer.length; i++){ | |
var timeStr = timesContainer[i].childNodes[0].innerHTML, | |
timeParts = timeStr.split(":"), | |
seconds = (timeParts[0] * 60) + parseInt(timeParts[1]); | |
timeSeconds += seconds; | |
} | |
var hours = (timeSeconds / 60) / 60, | |
minutes = (timeSeconds / 60) % 60, | |
seconds = (timeSeconds % 60), | |
result = parseInt(hours) + ":" + parseInt(minutes) + ":" + parseInt(seconds); | |
alert(result); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment