Last active
July 1, 2021 21:32
-
-
Save nakitadog/3e93c51f5b4f1dbac4dfc3907d5e4e54 to your computer and use it in GitHub Desktop.
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
var list=document.querySelector("ytd-section-list-renderer").querySelectorAll("a"); | |
var youtubeVideos = []; | |
for (i=0;i<list.length;i++){ | |
var url = list[i].getAttribute("href"); | |
if(url && url.indexOf("/watch?v=")>-1){ | |
var videoTitle = list[i].getAttribute("title"); | |
var videoID = list[i].getAttribute("href").replace(/https:\/\/www\.youtube\.com|\/watch\?v=|&t=.+s|&list=.*/gi,""); | |
if (youtubeVideos.indexOf(videoID) == -1 && videoTitle) { | |
youtubeVideos.push("https://www.youtube.com" + url + "\t" + videoID + "\t" + videoTitle); | |
} | |
} | |
} | |
youtubeVideos.sort(); | |
console.log("videoURL\tvideoID\tvideoTitle\n" + youtubeVideos.join("\n")); | |
var tempHolder = document.createElement("textarea"); | |
document.body.appendChild(tempHolder); | |
tempHolder.value = "videoURL\tvideoID\tvideoTitle\n" + youtubeVideos.join("\n"); | |
tempHolder.select(); | |
document.execCommand("copy"); | |
document.body.removeChild(tempHolder); | |
console.log("A total of " + youtubeVideos.length + " videoIDs were added to the clipboard."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment