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
| function scrapePlaylist() { | |
| // 0. go to https://www.youtube.com/playlist?list=WL and run this from the chrome dev console | |
| // 1. Extract the expected number of videos from the metadata | |
| const bylineItems = document.querySelectorAll('ytd-playlist-byline-renderer .byline-item'); | |
| let targetCount = 0; | |
| if (bylineItems.length > 0) { | |
| // Extracts digits from strings like "450 videos" or "1,234 views" | |
| const countText = bylineItems[0].innerText; | |
| targetCount = parseInt(countText.replace(/[^0-9]/g, ''), 10); |