Skip to content

Instantly share code, notes, and snippets.

@goodevilgenius
Created August 24, 2023 18:00
Show Gist options
  • Save goodevilgenius/633278374ffa2f8438e275dcede4f9db to your computer and use it in GitHub Desktop.
Save goodevilgenius/633278374ffa2f8438e275dcede4f9db to your computer and use it in GitHub Desktop.
Empty a YouTube playlist
function clickRemove() {
const button = [...document.querySelectorAll('.yt-formatted-string')].find(el => el.innerText === 'Remove from ');
if (!button) {
console.log("Can't find remove button");
return;
}
button.click();
setTimeout(emptyList, 1);
}
function emptyList() {
const hamburger = document.querySelector('ytd-playlist-video-renderer button[aria-label="Action menu"]');
if (!hamburger) {
console.log("Can't find hamburger menu");
return;
}
hamburger.click();
setTimeout(clickRemove, 500);
}
emptyList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment