Skip to content

Instantly share code, notes, and snippets.

@18520339
Last active February 25, 2022 17:45
Show Gist options
  • Save 18520339/34f5b5ce1c0a73a8637f22a2658cb5ae to your computer and use it in GitHub Desktop.
Save 18520339/34f5b5ce1c0a73a8637f22a2658cb5ae to your computer and use it in GitHub Desktop.
Calculate the total time of a Youtube playlist by seconds
[...document.querySelectorAll('ytd-thumbnail-overlay-time-status-renderer>span')].map(el => {
let timeSplit = el.innerText.split(':');
let lastIndex = timeSplit.length - 1;
let second = timeSplit[lastIndex] * 1;
for (let i = 0; i < lastIndex; i++)
second += timeSplit[i] * 60 ** (lastIndex - i);
return second;
}).reduce((total, second) => total + second);
/*
How to use:
1. Go to a Youtube playlist
2. Scroll to the last video of the playlist
3. F12 => Paste above code in the Console tab => Enter
4. The result is the total time of the playlist in seconds
Note: If the miniplayer at the bottom right is in use, close that and refresh the page
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment