Skip to content

Instantly share code, notes, and snippets.

@nakitadog
Last active July 1, 2021 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakitadog/3e93c51f5b4f1dbac4dfc3907d5e4e54 to your computer and use it in GitHub Desktop.
Save nakitadog/3e93c51f5b4f1dbac4dfc3907d5e4e54 to your computer and use it in GitHub Desktop.
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