Skip to content

Instantly share code, notes, and snippets.

@rudolfbyker
Last active February 8, 2018 20:52
Show Gist options
  • Save rudolfbyker/59b889157a70d6355e3134fbfbef38af to your computer and use it in GitHub Desktop.
Save rudolfbyker/59b889157a70d6355e3134fbfbef38af to your computer and use it in GitHub Desktop.
// Go to https://www.youtube.com/playlist?list=WL&disable_polymer=true
// Open the javascript console (CTRL+SHIFT+K in Firefox)
// Run the following code:
function loadMore() {
// Click the "Load More" button
var el = document.getElementsByClassName('browse-items-load-more-button');
if (el.length) {
el[0].click();
return true;
}
return false;
}
function sleep(ms) {
// From https://stackoverflow.com/a/39914235/836995
return new Promise(resolve => setTimeout(resolve, ms));
}
async function removeVideos() {
while(true){
var el = document.getElementsByClassName('pl-video-edit-remove'); // find the x
if (el.length) {
el[0].click(); // click the x to remove the video
await sleep(1000); // sleep, so as not to overload the connection
} else {
if (!loadMore()) { // try to load more videos
return; // stop if there is no load more button
}
}
}
}
removeVideos();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment