Created
October 17, 2024 08:22
-
-
Save dvygolov/b9e3aca6424b8553d1390f9e5c25beed to your computer and use it in GitHub Desktop.
Revisions
-
dvygolov created this gist
Oct 17, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ // Get all video elements on the page const videoElements = document.querySelectorAll('a#video-title-link'); // Ask user for the number of videos to process const numberOfVideos = parseInt(prompt("How many videos do you want to process?"), 10); // Initialize an empty string to store all video lines let videoList = ''; // Process the required number of video titles for (let i = 0; i < Math.min(numberOfVideos, videoElements.length); i++) { const video = videoElements[i]; const title = video.getAttribute('title'); const link = 'https://youtube.com' + video.getAttribute('href'); videoList += `${i + 1}. <a href="${link}">${title}</a>\n`; } // Log the entire list in a single console.log console.log(videoList);