Created
September 9, 2023 03:03
-
-
Save matheusolivesilva/eff424fba34167b92bb469cea7774868 to your computer and use it in GitHub Desktop.
Snippet that reads elapsed time in watched videos in 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
| const whatchedVideos = [] | |
| document.querySelectorAll('.style-scope.ytd-playlist-video-renderer').forEach(video => { | |
| const progress = video.querySelector('.style-scope.ytd-thumbnail-overlay-resume-playback-renderer') | |
| const title = video.querySelector('a#video-title') | |
| const duration = video.querySelector('#text') | |
| if(progress === null) return | |
| const progressAmount = Number(progress.style.width.replace('%', '')) | |
| const durationAmount = duration?.textContent?.trim() | |
| const isDuplicated = whatchedVideos.some(v => v.title === title?.title) | |
| if(progressAmount > 90 && !isDuplicated && !!title?.title) { | |
| whatchedVideos.push({ | |
| title: title?.title, | |
| durationAmount: `00:${durationAmount}` | |
| }) | |
| } | |
| }) | |
| console.table(whatchedVideos) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment