Skip to content

Instantly share code, notes, and snippets.

@shiroyuki
Last active November 7, 2017 04:22
Show Gist options
  • Save shiroyuki/d011bf7b9743bdc0d49deeaeee78472f to your computer and use it in GitHub Desktop.
Save shiroyuki/d011bf7b9743bdc0d49deeaeee78472f to your computer and use it in GitHub Desktop.
Youtube "Watch Later" Nuclear Button
function triggerReload() {
let loadMoreButton = document.querySelector('button.load-more-button');
if (!loadMoreButton) {
console.error('Unable to find the "load more" button.');
return false;
}
console.log('Trigger the reload.');
loadMoreButton.removeAttribute('onclick');
loadMoreButton.click();
return true;
}
class DelayDeletion {
constructor(target) {
this.target = target;
}
run() {
// console.log('R - TARGET:', this.target); return;
// Youtube uses onClick to prevent accidential clicks. We are removing this blocker.
this.target.removeAttribute('onclick');
// Then, simulate the click event.
this.target.click();
}
start(delay_in_ms) {
// The delay is to deal with the rate limiter.
setTimeout(this.run.bind(this), delay_in_ms);
}
}
function deleteAllVisibleEntries() {
let targets = document.querySelectorAll('button.pl-video-edit-remove');
let delay = 0;
console.warn('Deleting', targets.length);
if (targets.length === 0) {
return;
}
for (let e of targets) {
var dd = new DelayDeletion(e);
dd.start(++delay * 250);
}
}
deleteAllVisibleEntries();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment