Skip to content

Instantly share code, notes, and snippets.

@alqahtani
Created November 10, 2023 11:54
Show Gist options
  • Select an option

  • Save alqahtani/576277aee008f1049c17255cba335870 to your computer and use it in GitHub Desktop.

Select an option

Save alqahtani/576277aee008f1049c17255cba335870 to your computer and use it in GitHub Desktop.
Remove Liked videos on youtube
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function deleteNextVideo(id){
let menu = document.querySelectorAll("yt-icon-button[class='dropdown-trigger style-scope ytd-menu-renderer']")[id];
menu.click();
// Tiny delay to give the menu time to render
await sleep(300);
let menuItems = document.querySelector("tp-yt-paper-listbox[class='style-scope ytd-menu-popup-renderer']").children;
// In case of unavailable videos, there's only the remove button
let button = menuItems[5] ?? menuItems[0];
button.click();
}
// Just check how much you have in the playlist
let videos_count = 300;
for (i=1; i <= videos_count ; i++){
deleteNextVideo(if);
// 1500ms would get me 429 response after a couple of requests
await sleep(1750);
}
@alqahtani
Copy link
Author

alqahtani commented Nov 10, 2023

I used the code from this comment which works well for deleting videos on Watch Later Playlist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment