Repository navigation
Improve upvote / downvote comment handling - #39
paulmolluzzo wants to merge 3 commits into
Conversation
| const getUsername = () => $('meta[name="user-login"]').attr('content'); | ||
| const uselessContent = { | ||
| upvote: {text: ['+1\n'], emoji: [':+1:']}, | ||
| upvote: {text: ['+1\n'], emoji: [':+1:', ':100:']}, |
|
A couple of points:
|
|
I added in the acceptance of 👌 as an upvote and also fixed a bug I found. I also want to point out why this PR is better than just leaving the current implementation. A picture is worth 1000 words, so here are screenshots highlighting the differences. In all of these I'm the only user upvoting and downvoting a bunch of times. I think the PR is a marked improvement. No extension:Before the PR:After the plugin:To @hkdobrev's feedback:
This PR doesn't change the way @SpaceK33z decided to include/omit comments for votes. The logic in the I think @SpaceK33z made a good choice there. 👍
As I understand it, that's sort of the point of this extension. If it breaks because GitHub is improved, so be it. Relevant part in the README:
|
|
|
||
| const isUp = commentIsUseless('upvote', el); | ||
| const isDown = commentIsUseless('downvote', el); | ||
| const commenter = el.closest('.js-comment-container').getElementsByClassName('author')[0].innerHTML; |
There was a problem hiding this comment.
Why not just
const commenter = el.closest('.js-comment-container').find('author').get(0).innerHTML;There was a problem hiding this comment.
I don't see a big difference, but I changed it.
|
@sindresorhus I think this is complete actually. I don't want to get into comment parsing to leave text or consider the context of the content. That's super complex I think. What about using +1 in a math equation? Or when someone does +1000! Or a phrase like "if you actually make this work then 👍"? A comment with just a vote and nothing else is a vote. Everything else should stay. What do you think? |
👍 |
|
OK, updated title and first comment. This should be OK to do a review and merge if it's good. |
|
@paulmolluzzo Good stuff :) |



This is a WIP to fix #32. It solves 2 of the 3 items, but I don't know how to solve the last one perfectly. If we decide to omit it then maybe this PR is done.
As of the opening of this PR 💯 is an acceptable emoji to upvote. To add more acceptable emoji (or text) it can just be added to those arrays. @SpaceK33z set it up that way to begin with.
Now each upvote/downvote is only counted once per user. If the same user upvotes, then downvotes, then upvotes, it should effectively count as a single upvote. Voting 100 times in either direction counts as 1 vote.
Not done:
If the upvote / downvote is followed by some text, don't remove the comment but let it count.edit: not doing this since there are too many circumstances to consider. A comment with just a vote and nothing else is a vote. Everything else should stay.
It's not even just following text that's what you'll find. Sometimes the emoji can be at the end of the text. It can also be in the middle some place. And if you look at this issue you can see that there's even people complaining out all the +1's with no content, and those aren't votes, just arguing about voting. Not sure how to solve that one.