Created
January 10, 2026 07:35
-
-
Save AnmolTomer/8e1ec2bc260431650cae5752c3a01b03 to your computer and use it in GitHub Desktop.
Youtube Watch Later Playlist Management Scripts
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 removeVideos() { | |
| const videos = document.querySelectorAll('ytd-playlist-video-renderer'); | |
| let index = 0; | |
| function processVideo() { | |
| if (index >= videos.length) { | |
| console.log("Finished processing all videos."); | |
| return; | |
| } | |
| console.log(`Processing video ${index + 1}/${videos.length}...`); | |
| const menuButton = videos[index].querySelector("yt-icon-button button"); | |
| if (!menuButton) { | |
| console.log("Menu button not found, skipping."); | |
| index++; | |
| return setTimeout(processVideo, 500); | |
| } | |
| menuButton.click(); | |
| setTimeout(() => { | |
| const removeButton = [...document.querySelectorAll("tp-yt-paper-item")] | |
| .find(e => | |
| e.innerText.includes("Remove from Watch Later") || | |
| e.innerText.includes("Remove from Watch later") || | |
| e.innerText.includes("Fjern fra Se senere") | |
| ); | |
| if (removeButton) { | |
| removeButton.click(); | |
| console.log(`Removed video ${index + 1}`); | |
| } else { | |
| console.log("Remove button not found, skipping."); | |
| } | |
| index++; | |
| setTimeout(processVideo, 700); | |
| }, 700); | |
| } | |
| processVideo(); | |
| } | |
| removeVideos(); |
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 videoObj = {}; | |
| var links = document.getElementsByTagName("a"); | |
| for (var i = 0; i < links.length; ++i) { | |
| if (links[i] && links[i].href && links[i].href.match(/\/watch\?v=[-_a-zA-Z0-9]/)) { | |
| var url = links[i].href.replace(/&.*/, ""); // Clean URL | |
| var title = links[i].innerText.trim() || links[i].title || "Unknown Title"; // Extract title | |
| videoObj[url] = title; | |
| } | |
| } | |
| var videolist = ""; | |
| for (var url in videoObj) { | |
| videolist += url + " | " + videoObj[url] + "\n"; | |
| } | |
| var dataUrl = URL.createObjectURL(new Blob([videolist], { type: "text/plain;charset=utf-8;" })); | |
| var dlLink = document.createElement("a"); | |
| dlLink.href = dataUrl; | |
| dlLink.download = "youtube-video-ids.txt"; | |
| document.body.appendChild(dlLink); | |
| dlLink.click(); |
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
| let channels = {}; | |
| document.querySelectorAll("ytd-playlist-video-renderer").forEach(video => { | |
| let channel = video.querySelector("ytd-channel-name yt-formatted-string a")?.innerText.trim(); | |
| if (!channel) return; | |
| channels[channel] = (channels[channel] || 0) + 1; | |
| }); | |
| let threshold = 20; | |
| let smallChannels = Object.entries(channels) | |
| .filter(([_, count]) => count < threshold); | |
| let totalVideos = smallChannels.reduce((sum, [_, count]) => sum + count, 0); | |
| console.table(smallChannels.map(([channel,count]) => ({Channel: channel, Videos: count}))); | |
| console.log("Channels with < 20 videos:", smallChannels.length); | |
| console.log("Total videos that would be deleted:", totalVideos); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment