Skip to content

Instantly share code, notes, and snippets.

@charlesponti
Created June 1, 2026 21:21
Show Gist options
  • Select an option

  • Save charlesponti/29d116a655bad68ffa3ed44533f84978 to your computer and use it in GitHub Desktop.

Select an option

Save charlesponti/29d116a655bad68ffa3ed44533f84978 to your computer and use it in GitHub Desktop.
youtube.clear-likes
// Run on `https://www.youtube.com/playlist?list=LL`
(() => {
// Find all playlist video elements currently rendered on the page
const videos = document.querySelectorAll('ytd-playlist-video-renderer, ytd-playlist-panel-video-renderer');
let index = 0;
console.log(`Found ${videos.length} loaded videos. Starting the unlike process...`);
function processNextVideo() {
if (index >= videos.length) {
console.log('Finished processing all currently loaded videos!');
return;
}
const currentVideo = videos[index];
// Find and click the three-dot action menu button for the current video
const menuButton = currentVideo.querySelector('button[aria-label="Action menu"]');
if (menuButton) {
menuButton.click();
// Wait a moment for the popup menu to render in the DOM
setTimeout(() => {
// Look for the menu item containing the removal text
const menuItems = document.querySelectorAll('ytd-menu-service-item-renderer');
let removeButton = null;
for (const item of menuItems) {
if (item.innerText.includes('Remove from Liked videos')) {
removeButton = item;
break;
}
}
if (removeButton) {
removeButton.click();
console.log(`Unliked video #${index + 1}`);
} else {
console.log(`Could not find remove button for video #${index + 1} (it might be a deleted video entry)`);
// Close the menu if open so it doesn't obstruct the view
document.body.click();
}
index++;
// Introduce a 500ms delay between actions to protect against rate limits/UI lag
setTimeout(processNextVideo, 500);
}, 200);
} else {
index++;
processNextVideo();
}
}
// Start the execution loop
processNextVideo();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment