Skip to content

Instantly share code, notes, and snippets.

@matheusolivesilva
Created September 9, 2023 03:03
Show Gist options
  • Select an option

  • Save matheusolivesilva/eff424fba34167b92bb469cea7774868 to your computer and use it in GitHub Desktop.

Select an option

Save matheusolivesilva/eff424fba34167b92bb469cea7774868 to your computer and use it in GitHub Desktop.
Snippet that reads elapsed time in watched videos in a Youtube playlist
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