Watch Later playlists get out of hand fast. Built a small script to clean it up without having to sit there clicking remove on every video.
There are two versions. A simple one-liner if you just want it gone:
setInterval(() => {
try {
const video = document.getElementsByTagName('ytd-playlist-video-renderer')[0];
video.querySelector('#primary button[aria-label="Action menu"]').click();
document.evaluate(
'//span[contains(text(),"Remove from")]',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
).snapshotItem(0).click();
} catch (e) {}
}, 300);
And a more complete version with batch processing, retries, and configurable pacing if your playlist is massive:
const config = {
batchSize: 50,
deletionDelay: 800,
batchBreakTime: 1000 * 60 * 2,
maxRetries: 3,
debugMode: true
};
The config options are straightforward. batchSize is how many videos to process before taking a break, deletionDelay is the gap between each removal, and batchBreakTime is the pause between batches. The defaults work fine for most cases but if you’re hitting rate limits, bump up the delays and drop the batch size.
§Running it
Open your Watch Later playlist, hit F12, go to the Console tab, paste the script and press Enter. Keep the tab active while it runs.
On a slow connection, something like this works better:
const config = {
batchSize: 30,
deletionDelay: 1000,
batchBreakTime: 1000 * 60 * 3,
maxRetries: 4,
debugMode: true
};
On a fast connection you can push it a bit:
const config = {
batchSize: 75,
deletionDelay: 600,
batchBreakTime: 1000 * 60,
maxRetries: 2,
debugMode: true
};
If the script stops mid-way, refresh the page, wait a few minutes, and run it again. YouTube occasionally pushes UI changes that break the selectors too, so if it stops working entirely check the repo for updates.
Full code on GitHub. If you find it useful, a star would be appreciated. (ツ)
P.S. This works as of October 2024. YouTube changes their UI often enough that I can’t promise it’ll keep working forever. If something breaks, open an issue and I’ll take a look. (ツ)
