Load up https://myactivity.google.com/page?utm_source=my-activity&hl=en&page=youtube_comments and then run this in your browser console:

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);

Might need some tweaks since Google changes stuff all the time. Disclaimer: This isn’t my code.

Reply to this note

Please Login to reply.

Discussion

No replies yet.