Currently, most Youtube users are unable to remove watched videos from their Watch Later playlist using the 'Remove Watched Videos' button. This becomes a problem once users reach the maximum playlist size of 5000 videos and would otherwise have to manually remove videos from their playlist.
This simple console script will remove all fully watched videos from Watch Later playlist, bypassing the 502 error by removing each video individually.
- Go to your Watch Later playlist
- Open Developer Console pressing F12 or CTRL + SHIFT + I
- Paste the following code in the console and press Enter:
setInterval(function () {
watchedVideo = document.querySelector(`ytd-thumbnail-overlay-resume-playback-renderer > div.style-scope[style="width: 100%;"]`).closest('#content')
watchedVideoMenu = watchedVideo.nextElementSibling
watchedVideoMenu.querySelector('#primary button[aria-label="Action menu"]').click();
var things = document.evaluate(
'//span[contains(text(),"Remove from")]',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (var i = 0; i < things.snapshotLength; i++) {
things.snapshotItem(i).click();
}
}, 1000);
If you would also like to remove partially watched videos from the Watch Later playlist, you can use the following script (does not check for width: 100% on the 'resume-pĺayback' progress bar):
setInterval(function () {
watchedVideo = document.querySelector(`ytd-thumbnail-overlay-resume-playback-renderer`).closest('#content')
watchedVideoMenu = watchedVideo.nextElementSibling
watchedVideoMenu.querySelector('#primary button[aria-label="Action menu"]').click();
var things = document.evaluate(
'//span[contains(text(),"Remove from")]',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (var i = 0; i < things.snapshotLength; i++) {
things.snapshotItem(i).click();
}
}, 1000);
You might find that the script stops working, once it runs out of videos that have loaded. Here is a little code to scroll down the playlist and load more items.
setInterval(function() {
window.scrollBy(0, window.innerHeight);
}, 3000);
Putting the last two into a single function.
setInterval(function () {
watchedVideo = document.querySelector(`ytd-thumbnail-overlay-resume-playback-renderer`).closest('#content')
watchedVideoMenu = watchedVideo.nextElementSibling
watchedVideoMenu.querySelector('#primary button[aria-label="Action menu"]').click();
var things = document.evaluate(
'//span[contains(text(),"Remove from")]',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (var i = 0; i < things.snapshotLength; i++) {
things.snapshotItem(i).click();
}
window.scrollBy(0, window.innerHeight);
}, 1000);