Skip to content

Instantly share code, notes, and snippets.

@rochacbruno
Created February 9, 2024 14:16
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rochacbruno/dbedf63aa4d4d2909323facd9a0dc334 to your computer and use it in GitHub Desktop.
Save rochacbruno/dbedf63aa4d4d2909323facd9a0dc334 to your computer and use it in GitHub Desktop.
Delete youtube watch later

Delete whatch later videos from youtube

  • OPen youtube, change language to English
  • Go to your watch later playlist
  • OPen the inspect -> console
  • Paste the script and execute it
function deleteVideoFromWatchLater() {
video = document.getElementsByTagName('ytd-playlist-video-renderer')[0];
video.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();
}
}
async function deleteWatchLater() {
let batchSize = 200;
let waitBetweenBatchesInMilliseconds = 1000 * 60 * 5
let waitBetweenDeletionsInMilliseconds = 500;
let totalWaitTime = ((5000 / batchSize) * (waitBetweenBatchesInMilliseconds / 1000 / 60)) + (5000 * (waitBetweenDeletionsInMilliseconds / 1000 / 60))
console.log(`Deletion will take around ${totalWaitTime.toFixed(0)} minutes to run if the playlist is full.`);
let count = 0;
while (true) {
await new Promise(resolve => setTimeout(resolve, waitBetweenDeletionsInMilliseconds));
deleteVideoFromWatchLater();
count++;
if (count % batchSize === 0 && count !== 0) {
console.log('Waiting for 5 minutes...');
await new Promise(resolve => setTimeout(waitBetweenBatchesInMilliseconds));
}
}
}
deleteWatchLater();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment