Skip to content

Instantly share code, notes, and snippets.

@skylord123
Last active January 5, 2024 04:16
Show Gist options
  • Save skylord123/541ad2c390a6bbbd565e8dd76876ed48 to your computer and use it in GitHub Desktop.
Save skylord123/541ad2c390a6bbbd565e8dd76876ed48 to your computer and use it in GitHub Desktop.
Delete YouTube comments

Created this to make deleting my history easier. I tried at first deleting them all at once but the website would only delete a few and stop. Because of this I added a timeout of 4 seconds between each deletion which works great and prevents them from over-queueing. Also added a console.log statement so you can see the progress.

  1. Copy the contents of code.js
  2. Go to https://www.youtube.com/feed/history/comment_history
  3. Hold down Page Down button until you reach the end of the history
  4. Open developer console (can open from hamburger menu or pressing F12 in Windows)
  5. Paste the code into the console and run it (you may have to right click and hit "Force Paste")
var items = document.querySelectorAll('[aria-label~="Delete"]');
for( var x = 0; x < items.length; x++ ){
console.log(`${x+1}/${items.length+1}`);
await new Promise(r => setTimeout(r, 4000));
var evObj = document.createEvent('Events');
evObj.initEvent('click', true, false);
items[x].dispatchEvent(evObj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment