Skip to content

Hide useless comments - #1526

Merged
sindresorhus merged 6 commits into
refined-github:masterfrom
fregante:useless-comments
Sep 17, 2018
Merged

sindresorhus merged 6 commits into
refined-github:masterfrom
fregante:useless-comments

Conversation

@fregante

Copy link
Copy Markdown
Member

Closes #1478

Testable on hayaku/hayaku#303

This is how the comments reappear after clicking "Undo"

let uselessCount = 0;
for (const commentText of select.all('.comment-body > p:only-child')) {
// Find useless comments
if (!/^(\+[120]+!?|👍|🙏)$/.test(commentText.textContent.trim())) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you support -1 and 👎 too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surr

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bfred-it don't you mean 👍 ;)

@fregante fregante Sep 14, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:+1:

@yakov116

Copy link
Copy Markdown
Member

Can the note be on top and on bottom of the page?

@fregante

Copy link
Copy Markdown
Member Author

Why?

@yakov116

Copy link
Copy Markdown
Member

@bfred-it in a long conversation you would have to scroll down to unhide nvm it does not make sense...

@yakov116

Copy link
Copy Markdown
Member

When unhiding more comments it does not hide them. Is that done purposely?

@fregante

Copy link
Copy Markdown
Member Author

Yeah it does not watch the page for new comments be uncollapsed comments, I thought that if you click that and nothing happens it would seem confusing/broken. So it’s best to leave the useless comments visible.

@sindresorhus

Copy link
Copy Markdown
Member

Looks good. Just needs to be added to the readme.

@sindresorhus
sindresorhus merged commit ee9375a into refined-github:master Sep 17, 2018
@fregante
fregante deleted the useless-comments branch September 17, 2018 04:17
@yakov116

Copy link
Copy Markdown
Member

@bfred-it sindresorhus/ama#363 (comment)

Hides 👍 👎 comments and shows their count in the sidebar

When there's only a few of them they might just be "okay, that works" rather than "I vote for this feature"

Flash back 😄

@fregante

fregante commented Sep 17, 2018 •

Copy link
Copy Markdown
Member Author

You found that 😂

Glad that the reasoning still applies. Conversational +1’s aren’t removed (however it doesn’t consider the count)

@Mottie

Mottie commented Sep 17, 2018

Copy link
Copy Markdown
Contributor

Yeah it does not watch the page for new comments be uncollapsed comments

It doesn't appear to be checking for useless comments when the "xxx hidden items Load more..." button is clicked; like on this page.

And I don't think it catches comments like "+1!" (exclamation points). There's a lot of them in that thread.

@fregante

fregante commented Sep 18, 2018 •

Copy link
Copy Markdown
Member Author

It doesn't appear to be checking for useless comments when the "xxx hidden items Load more..." button is clicked; like on this page.

Refer to #1526 (comment). I suppose the alternative would be to show "xx comments were hidden" near the clicked button

And I don't think it catches comments like "+1!" (exclamation points). There's a lot of them in that thread.

+111111!!!!!! comments are caught (/^([+-]\d+!*|👍|🙏|👎|👌)+$/) but in that thread they're lazy-loaded and lazy-loaded comments aren't handled.

screen shot 2018-09-18 at 08 55 14 (screenshot from hayaku/hayaku#303)

@darkred

darkred commented Sep 18, 2018 •

Copy link
Copy Markdown
Contributor

The "xxx useless comments were hidden" count is incorrect, greater than the comments total count:
in the test URL, hayaku/hayaku#303, it's "123 useless comments were hidden",
but in the first post there it's shown that there are "102 comments" in total.

The comments that actually become hidden is ~70.

(tested in both Chrome 69 And Firefox 62, with no disabled features in the extension, and no other extension enabled)

A screenshot I kept: 2018-09-18_204557

@darkred

darkred commented Sep 21, 2018 •

Copy link
Copy Markdown
Contributor

(Follow-up to my comment above)

in case you visit the test page, hayaku/hayaku#303 now,
the "xxx hidden items Load more..." button now has 45:
(in my comment above, three days ago, it had 25)
2018-09-21_234657

the page still has the same comments count, 102:
2018-09-21_234617

and the extension currently shows a different, still incorrect count,"86 useless comments were hidden"
2018-09-21_234645
while, if I'm not mistaken, the actually hidden comments count is now 44.

PS. Chrome 69, extension version 18.9.19.1710.

@fregante

Copy link
Copy Markdown
Member Author

I think you’re right. The miscount is because GitHub sends the same comment twice in the code to enable some features. To fix it, the first selector needs to include .unminimized-comment or something like that.

@hubertgrzeskowiak

Copy link
Copy Markdown

For me this also hides relevant, longer comments, including review comments.

@fregante

fregante commented Sep 25, 2018 •

Copy link
Copy Markdown
Member Author

Can you show an example of “longer comment” hidden?

@hubertgrzeskowiak

hubertgrzeskowiak commented Sep 26, 2018 •

Copy link
Copy Markdown

With hidden comments:
screen shot 2018-09-26 at 2 29 43 pm

After undoing the effects of this plugin:
screen shot 2018-09-26 at 2 29 55 pm

Note the Friendly reminder message on top of both screenshots as a reference point.

@fregante

Copy link
Copy Markdown
Member Author

Oof, yes, the selector needs some tweaking on PRs. I only tested this on issues. #1544 will fix this at least temporarily

@refined-github refined-github locked as resolved and limited conversation to collaborators Mar 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

7 participants