Skip to content

Instantly share code, notes, and snippets.

@gajeshbhat
Created April 20, 2025 23:10
Show Gist options
  • Save gajeshbhat/0ca6ced9e455b5d4679920c8cf989b4f to your computer and use it in GitHub Desktop.
Save gajeshbhat/0ca6ced9e455b5d4679920c8cf989b4f to your computer and use it in GitHub Desktop.
Remove all videos from your YouTube "Liked Videos" playlist using JavaScript in the browser console
/**
* πŸ”₯ Script to automatically remove all videos from your YouTube "Liked Videos" playlist.
*
* πŸ“Œ How it works:
* - Scrolls to each video in the Liked Videos playlist
* - Opens the three-dot menu
* - Clicks "Remove from Liked videos"
*
* πŸ’‘ Usage:
* 1. Go to your Liked Videos playlist: https://www.youtube.com/playlist?list=LL
* 2. Scroll to the bottom of the page to load all videos, Optionally clikc on the eye icon to also show unavailable videos so that they are also deleted
* 3. Open your browser's Developer Console (Ctrl+Shift+I or Cmd+Opt+I)
* 4. Type `allow pasting` and hit enter to enable pasting.
* 5. Paste and run this script
*
* βœ… Confirmed working as of April 2025
* 🚫 This only removes videos that are currently loaded in the DOM, so be sure to scroll all the way down first.
*/
async function removeFromLikedVideos() {
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const menuButtons = Array.from(document.querySelectorAll('ytd-menu-renderer yt-icon-button'));
console.log(`Found ${menuButtons.length} videos with menu buttons.`);
for (let i = 0; i < menuButtons.length; i++) {
try {
menuButtons[i].scrollIntoView({ behavior: "smooth", block: "center" });
menuButtons[i].click();
await sleep(500);
const menuItems = document.querySelectorAll('ytd-menu-service-item-renderer');
for (let item of menuItems) {
if (item.innerText.includes('Remove from Liked videos')) {
item.click();
console.log(`Removed liked video #${i + 1}`);
break;
}
}
await sleep(1000); // longer pause to avoid overload
} catch (e) {
console.error(`Failed at video #${i + 1}:`, e);
}
}
console.log("βœ… Finished removing all liked videos!");
}
removeFromLikedVideos();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment