Last active
October 26, 2023 11:20
-
-
Save rauschma/d5b8d97004ae8a94911d940002e21df7 to your computer and use it in GitHub Desktop.
This file contains 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
// 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