Skip to content

Instantly share code, notes, and snippets.

@rauschma
Last active October 26, 2023 11:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rauschma/d5b8d97004ae8a94911d940002e21df7 to your computer and use it in GitHub Desktop.
Save rauschma/d5b8d97004ae8a94911d940002e21df7 to your computer and use it in GitHub Desktop.
// Batch-delete videos from YouTube’s “Watch later” playlist
// Paste the following code into a browser console while the playlist is open
// Code based on: https://gist.github.com/astamicu/eb351ce10451f1a51b71a1287d36880f?permalink_comment_id=4087416#gistcomment-4087416
//
// (Suggestions for improvement welcome. My approach for waiting for the .click() to finish, feels hacky.)
const pause = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function remove() {
for (let i=0; i < 100; i++) {
document.querySelector('#primary button[aria-label="Action menu"]').click();
await pause(0);
document.evaluate('//span[contains(text(),"Remove from")]', document, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0).click();
await pause(500);
}
}
remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment