Skip to content

Instantly share code, notes, and snippets.

@MaxenceMottard
Created June 7, 2022 07:47
Show Gist options
  • Save MaxenceMottard/4ce33b30394310beb25329861342b455 to your computer and use it in GitHub Desktop.
Save MaxenceMottard/4ce33b30394310beb25329861342b455 to your computer and use it in GitHub Desktop.
const items = Array.from(document.querySelectorAll('#wwdc22 .collection-items .collection-item'))
let videos = {}
items
.map((item) => ({
title: item.querySelector('.video-title').innerText,
url: item.querySelector('.video-image-link').href,
image: item.querySelector('.video-image').src,
date: Array.from(item.querySelectorAll('span'))
.map((span) => span.innerText)
.find((text) => text.includes("Available on")) ?? 'Monday'
}))
.forEach((video) => {
if (!videos[video.date]) {
videos[video.date] = []
}
videos[video.date].push(video)
})
Object.keys(videos)
.reverse()
.map((category) =>
`# **${category}**\n` + videos[category]
.map((video) => `- [${video.title}](${video.url})`)
.join('\n')
)
.join('\n\n\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment