Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove all comments from GitHub Pull Request
// Sometimes it's necessary to do a bit of clean-up
Array.prototype.forEach.call(document.querySelectorAll('.js-comment-delete button'), function(el, i) {
el.removeAttribute('data-confirm');
el.click();
});
@thiagogabriel
Copy link

thiagogabriel commented Mar 21, 2018

Still working. Thanks.

@nachtien
Copy link

nachtien commented Jun 7, 2018

Any luck on getting it to just hide the comments instead of deleting them?

@dienncrelipa
Copy link

dienncrelipa commented Aug 2, 2018

Still working, perfect. Thanks

@haridsv
Copy link

haridsv commented May 12, 2020

This still works! We had a service user that logged a lot of spam comments on a PR, so I used this code to remove only those comments:

var comment_headers = document.querySelectorAll('.timeline-comment');
for (var i = 0; i < comment_headers.length; i++) {
    var button = comment_headers[i].querySelector('.js-comment-delete button');
    if (button) {
        if (comment_headers[i].querySelector('.author').text == '<service-account-name>') {
            button.removeAttribute('data-confirm');
            button.click();
        }
    }
}

@druchoo
Copy link

druchoo commented Jul 8, 2020

Still works. If you have many comments that are folded, you'll need to expand them first.

@Trijeet
Copy link

Trijeet commented Dec 2, 2020

Still works. Thanks.

@mimaty-lifull
Copy link

mimaty-lifull commented Jul 6, 2021

Still works. Thanks.

@kylechadha
Copy link

kylechadha commented Jun 24, 2022

I wanted to resolve ~100 comments and was able to use this:

Array.prototype.forEach.call(document.querySelectorAll('.js-resolvable-timeline-thread-form button'), function(el, i) {
  el.click()
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment