Last active
January 18, 2025 21:42
-
-
Save alane019/4eb230477f6b495d0235b72f318bbfc3 to your computer and use it in GitHub Desktop.
Delete remove all videos from Youtube "Watch Later" playlist (working as of 12/14/2020)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script can be used to clear all videos from youtube's built-in "watch later" playlist which has a limit of 5,000 videos. | |
// Without this, you would need to click the remove button on each video in the list. | |
// Youtube made changes recently that caused errors for a previously working script. | |
// Script written by: janthedeveloper (https://github.com/JanTheDeveloper) | |
// Bookmark wrapper added by: shelldonhull (https://github.com/sheldonhull) | |
// Full conversation here: https://gist.github.com/astamicu/eb351ce10451f1a51b71a1287d36880f#file-readme-md | |
// 1. Save the javascript text below as a bookmark in google chrome(Simply replace the URL field in any existing bookmark, and give the bookmark any name) | |
javascript:(() => {setInterval(function () { document.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); })(); | |
// 2.) Enter this exact URL into google chrome web browswer: https://www.youtube.com/playlist?list=WL&disable_polymer=true | |
// NOTE 1: THE URL MUST END WITH "&disable_polymer=true" | |
// NOTE 2: You'll need to be signed into your youtube account when using this URL, if you're not already. | |
// 3.) Once you're on the correct Watch Later playlist page, click the bookmark that you saved in the step 1. This will start deleting videos. | |
// Source: https://gist.github.com/astamicu/eb351ce10451f1a51b71a1287d36880f#gistcomment-3552367 (as of 12/14/2020) | |
// You can save any javascript snippet as a bookmark and run as needed using this format: | |
// javascript:(() => { REPLACE_THIS_TEXT_WITH_SCRIPT })(); | |
// If page is being displayed in language other than English, see comment from Gater73 below. Update portions on html tags that vary based on language. | |
// Full script, without the bookmark wrapper code below (This could be entered into the chrome dev-tools console as an alternative to using the bookmarked script) | |
setInterval(function () { | |
document.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); | |
MacOS. Doesn't work for me because of problem below:
Uncaught TypeError: Cannot read properties of null (reading 'click')
at :1:103
How to solve this?
@ArthurYdalgo 's code works well, without throwing into 5xx errors. Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Previously posted this here
Not sure how good this is, but worked for me. Since there's no language dependent querySelector, should work for most people (I hope...)
Caveat: It might take a while, but just leave it doing it's thing
It works on this url: https://www.youtube.com/playlist?list=WL
There were over 2000+ videos on my watch later. I tried removing the ones I had already watched using the Youtube's built in feature, but the request would eventually throw me a 502 after a minute or so of waiting.