0

Ever wanted to remove your entire comment history quickly without deleting your channel?

Apparently I need a minimum amount of characters to post

Josh Maxwell
  • 79
  • 10

3 Answers3

0

Couldn't find an answer anywhere so I thought I'd share

Go to history, in the left pane find comments, open inspector and paste this into the console. It just gets every 'X' button by a CSS selector, and for each one it simulates a click. Easy

If it doesn't work, check that they didn't modify the CSS since I posted this

var items = document.querySelectorAll('[aria-label="Delete activity item"]');
for( var x = 0; x < items.length; x++ ){
    var evObj = document.createEvent('Events');
    evObj.initEvent('click', true, false);
    items[x].dispatchEvent(evObj);
}
Josh Maxwell
  • 79
  • 10
0

they changed the label to include the full comment so each X has a different label. this now just looks for the word Delete that is at the start of each label for the X

var items = document.querySelectorAll('[aria-label~="Delete"]');
    for( var x = 0; x < items.length; x++ ){
        var evObj = document.createEvent('Events');
        evObj.initEvent('click', true, false);
        items[x].dispatchEvent(evObj);
    }
obz
  • 26
0

A little late to the party but this is my solution for 2022:

function scrollDown(i) {
  try {
    window.scrollTo(0, document.body.scrollHeight); 
  }
  catch (e) {
    scrollDown();
  }
  setTimeout(function(){
    var i = i - '20'; // just to make sure we dont skip any comments while scrolling
    deleteComment(i);
  }, 1000);
}

function deleteComment(i) {
  
  var xPathRes = document.evaluate ('/html/body/c-wiz/div/div[2]/c-wiz/c-wiz/div/div[2]/div[1]/div', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; 
  if (xPathRes) {
    if (xPathRes.textContent == "Looks like you've reached the end") {
      console.log("All done! Keep the page open until everything is gone including the grey date bubbles");
      return;
    }
  }
  
  console.log('Deleting comment: ' + i);
  
  var xPathRes = document.evaluate ('/html/body/c-wiz/div/div[2]/c-wiz/c-wiz/div/div[1]/c-wiz[' + i + ']/div/div/div[1]/div[2]/div/button', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
  
  var i = i + 1;
  if (i > 500) {
    return;
  }
  
  try {
    xPathRes.singleNodeValue.click();
  }
  catch (e) {
    scrollDown(i);
    return;
  }
  
  deleteComment(i);
}


deleteComment(1);

!! Be aware that this script is not perfect. I coded it in a hurry. If the script didn't delete everything, just paste it again and keep the page open untill everything is gone (it takes a while to process all the requests)

The script will halt after it sees the "looks like you've reached the end" text.

This script works on: https://myactivity.google.com/page?utm_source=my-activity&hl=en&page=youtube_comments

Niels
  • 1,005
  • 1
  • 8
  • 18