Last active
September 9, 2023 03:03
-
-
Save matheusolivesilva/22761cccfc22199eb7aadea5c71414dc to your computer and use it in GitHub Desktop.
Snippet that reads Netflix elapsed time in a season
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
| let totalInMinutes = 0 | |
| document.querySelectorAll('.episodeSelector-container span.duration.ellipsized').forEach(duration => { | |
| const durationInMinutes = Number(duration.textContent.replace(/m|h/g, '')); | |
| totalInMinutes += durationInMinutes | |
| }) | |
| const minutesInOneHour = 60 | |
| const hours = Math.trunc(totalInMinutes / minutesInOneHour) | |
| const minutes = totalInMinutes % minutesInOneHour | |
| console.log(`${hours}:${minutes}:00`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment