Skip to content

Instantly share code, notes, and snippets.

@davidroman0O
Last active November 22, 2023 13:07
Show Gist options
  • Save davidroman0O/eb6f0685ce9eeba256df034ef13d4e28 to your computer and use it in GitHub Desktop.
Save davidroman0O/eb6f0685ce9eeba256df034ef13d4e28 to your computer and use it in GitHub Desktop.
Delete all "Watch later" videos

It's semi-automated at worse, automated at best

open browser

open inspector on console

copy paste, enter

wait

if nothing is deleted, might be a timeout from youtube, refresh page, back step 1

until completion

Eventually Youtube won't re-load automatically your Watch Later videos, so you might have to refresh the page.

When you have the 5k rows, you might have to do it multiple times.

Some videos might be deleted or in private, you have an option on the three dots "burger" menu to toggle them.

It will take you a while, the browser need to stay active otherwise the code of YT won't refresh the video list and sometimes it just doesn't, so you will have to refresh and re-execute.

Happy deletion!

function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
(async () => {
var vids = [...document.getElementsByTagName("ytd-playlist-video-renderer")];
var maxRetries = 10;
while (vids.length > 0) {
for (let index = 0; index < vids.length; index++) {
const element = vids[index];
console.log("clicked on video", element)
element.querySelectorAll("button")[0].click()
console.log("wait popup")
await delay(500);
console.log("click on delete watch later")
var btns = document.getElementsByTagName("ytd-menu-service-item-renderer")
if (btns.length == 1) {
// hidden videos
document.getElementsByTagName("ytd-menu-service-item-renderer")[0].click()
} else {
document.getElementsByTagName("ytd-menu-service-item-renderer")[2].click()
}
}
console.log("done with current list, will restart in 5s")
await delay(5000); // wait 5 seconds for youtube to reload the list
for (let retries = 0; retries < maxRetries; retries++) {
vids = [...document.getElementsByTagName("ytd-playlist-video-renderer")];
if (vids.length > 0) {
console.log("relooping with", vids.length)
break
}
await delay(5000); // wait 5 seconds for youtube to reload the list
console.log("i guess we will wait again")
}
console.log("it's over")
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment