Last active
May 25, 2024 15:38
-
-
Save zoyo23/e4050ba6a2f672949f39bb6beca0694c 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.
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() { | |
var timeSeconds = 0; | |
var timestampList = document.querySelectorAll("div#content div#container ytd-thumbnail#thumbnail a#thumbnail div#overlays.style-scope.ytd-thumbnail.style-scope ytd-thumbnail-overlay-time-status-renderer span"); | |
for(var i = 0; i < timestampList.length; i++) { | |
var timestampDiv = timestampList[i]; | |
var timeStr = timestampDiv.innerHTML.replace("\n", "").replace("\n", "").trim(); | |
var timeParts = timeStr.split(":"); | |
var seconds = (timeParts[0] * 60) + parseInt(timeParts[1]); | |
timeSeconds += seconds; | |
} | |
var hours = (timeSeconds / 60) / 60; | |
var minutes = (timeSeconds / 60) % 60; | |
var seconds = (timeSeconds % 60); | |
var result = parseInt(hours) + ":" + parseInt(minutes) + ":" + parseInt(seconds); | |
var mensagem = `Tempo total Playlist: ${result}`; | |
console.log(mensagem); | |
alert(mensagem); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment