Created
February 9, 2019 21:16
-
-
Save rgson/9ad3b42244ed4bde6fb0e211bde1587f to your computer and use it in GitHub Desktop.
Calculates the total duration of a YouTube 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
/* | |
Calculates the total duration of a YouTube playlist. | |
Run the snippet in Chrome Dev Tools while on the playlist's page, | |
e.g. https://www.youtube.com/playlist?list=WL | |
Ensure that the playlist is fully visible first. | |
Long playlists are loaded 100 videos at a time. | |
*/ | |
new Date(1000 * | |
[...document.getElementsByTagName('ytd-thumbnail-overlay-time-status-renderer')] | |
.map(e => e | |
.textContent | |
.split(':') | |
.reverse() | |
.map((n, i) => n * Math.pow(60, i))) | |
.flat() | |
.reduce((a, b) => a + b, 0)) | |
.toISOString() | |
.substr(11, 8); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment