(function(){ function deleteNext() { const videoItem = document.querySelector('ytd-playlist-video-renderer'); if (!videoItem) { console.log("No more videos found."); return; } const menuButton = videoItem.querySelector('yt-icon-button.dropdown-trigger button[aria-label="Action menu"]'); if (!menuButton) { console.log("Action menu button not found."); return; } menuButton.click(); setTimeout(() => { // Select the third menu item from the listbox (assumed to be "Remove from Watch Later") const menuItem = document.querySelector('tp-yt-paper-listbox#items > ytd-menu-service-item-renderer:nth-of-type(3) tp-yt-paper-item'); if (menuItem) { menuItem.click(); setTimeout(deleteNext, 1000); } else { console.log("Menu item not found, retrying..."); setTimeout(deleteNext, 500); } }, 500); } deleteNext(); })();