Created
March 25, 2020 14:13
-
-
Save kiliczsh/139ce2c60431877f382e06c8c3e0b702 to your computer and use it in GitHub Desktop.
Youtube Playlist Total Time Length Finder for Firefox Web Console
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
| var collection = document.getElementsByClassName("style-scope ytd-thumbnail-overlay-time-status-renderer"); | |
| var arr = [] | |
| for (var i = 0; i < collection.length; i++) { | |
| if (collection[i].tagName.endsWith('SPAN')) { | |
| arr.push(collection[i]); | |
| } | |
| } | |
| var total_sec = 0; | |
| for (var j = 0; j < arr.length; j++) { | |
| var hms = arr[j].firstChild.textContent.trim().split(":"); | |
| if (hms.length == 3) { | |
| total_sec += parseInt(hms[2].trim()) + (parseInt(hms[1].trim()) * 60) + (parseInt(hms[0].trim()) * 60 * 60); | |
| } else if (hms.length == 2) { | |
| total_sec += parseInt(hms[1].trim()) + (parseInt(hms[0].trim()) * 60); | |
| } else if (hms.length == 1) { | |
| total_sec += parseInt(hms[0].trim()); | |
| } | |
| } | |
| var date = new Date(null); | |
| date.setSeconds(total_sec); | |
| var result = date.toISOString().substr(11, 8); | |
| console.log("Total lenght of this playlist is: " + result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment