{"action":"created","comment":{"url":"https://api.github.com/repos/sindresorhus/refined-github/pulls/comments/58699199","id":58699199,"diff_hunk":"@@ -0,0 +1,58 @@\n+const addReactionParticipants = {\n+\tadd(currentUser) {\n+\t\t$('.comment-reactions.has-reactions').each((index, reactionsContainer) => {\n+\t\t\tconst $reactionsContainer = $(reactionsContainer);\n+\t\t\tconst $reactionButtons = $reactionsContainer.find('.comment-reactions-options .reaction-summary-item[aria-label]');\n+\n+\t\t\t$reactionButtons.each((index, element) => {\n+\t\t\t\tconst participantCount = Number(element.innerHTML.split('/g-emoji>')[1]);\n+\t\t\t\tconst participants = element.getAttribute('aria-label')\n+\t\t\t\t\t.replace(/,? and /, ', ')\n+\t\t\t\t\t.replace(/, \\d+ more/, '')\n+\t\t\t\t\t.split(', ');\n+\t\t\t\tconst userPosition = participants.indexOf(currentUser);\n+\n+\t\t\t\t// if the user is the only participant, leave as is\n+\t\t\t\tif (participantCount === 1 && userPosition > -1) {\n+\t\t\t\t\treturn;\n+\t\t\t\t}\n+\n+\t\t\t\t// add participant container\n+\t\t\t\tif ($(element).find('div.participants-container').length === 0) {\n+\t\t\t\t\t$(element).append('<div class=\"participants-container\">');\n+\t\t\t\t}\n+\n+\t\t\t\t// remove self from participant list so you don't see your own avatar\n+\t\t\t\tif (userPosition > -1) {\n+\t\t\t\t\tparticipants.splice(userPosition, 1);\n+\t\t\t\t}\n+\n+\t\t\t\tconst firstThreeParticipants = participants.slice(0, 3);\n+\t\t\t\tconst participantsContainer = $(element).find('.participants-container').get(0);\n+\n+\t\t\t\t// clear any existing avatars and remainder count\n+\t\t\t\t$(participantsContainer).html('');\n+\n+\t\t\t\tfor (const participant of firstThreeParticipants) {\n+\t\t\t\t\t$(participantsContainer).append(`<img src=\"https://github.com/${participant}.png\">`);\n+\t\t\t\t}\n+\t\t\t});\n+\t\t});\n+\t},\n+\n+\treapply(event, currentUser) {\n+\t\tif (!$(event.target).closest('button').not('.add-reaction-btn').is('.add-reactions-options-item, .reaction-summary-item')) {\n+\t\t\treturn;\n+\t\t}\n+\t\tconst applyReactions = setInterval(() => {\n+\t\t\taddReactionParticipants.add(currentUser);\n+\t\t\tclearInterval(applyReactions);\n+\t\t}, 500);\n+\t},\n+\n+\taddListener(username) {\n+\t\tdocument.addEventListener('click', event => {\n+\t\t\taddReactionParticipants.reapply(event, username);\n+\t\t});\n+\t}","path":"extension/reactions-avatars.js","position":57,"original_position":57,"commit_id":"be57a4374c499857a1611f256c0ac121afbf4059","original_commit_id":"be57a4374c499857a1611f256c0ac121afbf4059","user":{"login":"hkdobrev","id":506129,"avatar_url":"https://avatars.githubusercontent.com/u/506129?v=3","gravatar_id":"","url":"https://api.github.com/users/hkdobrev","html_url":"https://github.com/hkdobrev","followers_url":"https://api.github.com/users/hkdobrev/followers","following_url":"https://api.github.com/users/hkdobrev/following{/other_user}","gists_url":"https://api.github.com/users/hkdobrev/gists{/gist_id}","starred_url":"https://api.github.com/users/hkdobrev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hkdobrev/subscriptions","organizations_url":"https://api.github.com/users/hkdobrev/orgs","repos_url":"https://api.github.com/users/hkdobrev/repos","events_url":"https://api.github.com/users/hkdobrev/events{/privacy}","received_events_url":"https://api.github.com/users/hkdobrev/received_events","type":"User","site_admin":false},"body":"You could rename `username` to `currentUser` for consistency and even put the `reapply` function body in `addListener` itself as reapplying only makes sense at the moment in the context of an event listener.","created_at":"2016-04-06T12:56:24Z","updated_at":"2016-04-06T12:56:24Z","html_url":"https://github.com/sindresorhus/refined-github/pull/145#discussion_r58699199","pull_request_url":"https://api.github.com/repos/sindresorhus/refined-github/pulls/145","_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/refined-github/pulls/comments/58699199"},"html":{"href":"https://github.com/sindresorhus/refined-github/pull/145#discussion_r58699199"},"pull_request":{"href":"https://api.github.com/repos/sindresorhus/refined-github/pulls/145"}}},"pull_request":{"url":"https://api.github.com/repos/sindresorhus/refined-github/pulls/145","id":65056742,"html_url":"https://github.com/sindresorhus/refined-github/pull/145","diff_url":"https://github.com/sindresorhus/refined-github/pull/145.diff","patch_url":"https://github.com/sindresorhus/refined-github/pull/145.patch","issue_url":"https://api.github.com/repos/sindresorhus/refined-github/issues/145","number":145,"state":"open","locked":false,"title":"Add avatars for reactions participants","user":{"login":"paulmolluzzo","id":737065,"avatar_url":"https://avatars.githubusercontent.com/u/737065?v=3","gravatar_id":"","url":"https://api.github.com/users/paulmolluzzo","html_url":"https://github.com/paulmolluzzo","followers_url":"https://api.github.com/users/paulmolluzzo/followers","following_url":"https://api.github.com/users/paulmolluzzo/following{/other_user}","gists_url":"https://api.github.com/users/paulmolluzzo/gists{/gist_id}","starred_url":"https://api.github.com/users/paulmolluzzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulmolluzzo/subscriptions","organizations_url":"https://api.github.com/users/paulmolluzzo/orgs","repos_url":"https://api.github.com/users/paulmolluzzo/repos","events_url":"https://api.github.com/users/paulmolluzzo/events{/privacy}","received_events_url":"https://api.github.com/users/paulmolluzzo/received_events","type":"User","site_admin":false},"body":"Hat tip to @hkdobrev for getting this started and finding the way to get GH user avatars.\r\n\r\nThis extends the work @hkdobrev did on a new branch that is also up to date with `master`. Basically, it takes the avatars of people who add a reaction to a comment and appends their avatar. I am only appending the first 3 (or less) avatars because it quickly gets crazy, and then just add `+${remainder}` at the end.\r\n\r\nSuggestions on the design are welcome. I'm thinking we can even get rid of the original number, but not sure.\r\n\r\nExample:\r\n![reaction-avatars](https://cloud.githubusercontent.com/assets/737065/14230374/ca390f4a-f921-11e5-92a8-c1d81ce51b4c.png)\r\n","created_at":"2016-04-03T02:25:58Z","updated_at":"2016-04-06T12:56:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3703a3375ebf2df5ed403ccfb429e69ef7eedc0e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sindresorhus/refined-github/pulls/145/commits","review_comments_url":"https://api.github.com/repos/sindresorhus/refined-github/pulls/145/comments","review_comment_url":"https://api.github.com/repos/sindresorhus/refined-github/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sindresorhus/refined-github/issues/145/comments","statuses_url":"https://api.github.com/repos/sindresorhus/refined-github/statuses/be57a4374c499857a1611f256c0ac121afbf4059","head":{"label":"sindresorhus:reactions-participants-new","ref":"reactions-participants-new","sha":"be57a4374c499857a1611f256c0ac121afbf4059","user":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"repo":{"id":51769689,"name":"refined-github","full_name":"sindresorhus/refined-github","owner":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sindresorhus/refined-github","description":"Chrome extension that simplifies the GitHub interface and adds useful features","fork":false,"url":"https://api.github.com/repos/sindresorhus/refined-github","forks_url":"https://api.github.com/repos/sindresorhus/refined-github/forks","keys_url":"https://api.github.com/repos/sindresorhus/refined-github/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sindresorhus/refined-github/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sindresorhus/refined-github/teams","hooks_url":"https://api.github.com/repos/sindresorhus/refined-github/hooks","issue_events_url":"https://api.github.com/repos/sindresorhus/refined-github/issues/events{/number}","events_url":"https://api.github.com/repos/sindresorhus/refined-github/events","assignees_url":"https://api.github.com/repos/sindresorhus/refined-github/assignees{/user}","branches_url":"https://api.github.com/repos/sindresorhus/refined-github/branches{/branch}","tags_url":"https://api.github.com/repos/sindresorhus/refined-github/tags","blobs_url":"https://api.github.com/repos/sindresorhus/refined-github/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sindresorhus/refined-github/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sindresorhus/refined-github/git/refs{/sha}","trees_url":"https://api.github.com/repos/sindresorhus/refined-github/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sindresorhus/refined-github/statuses/{sha}","languages_url":"https://api.github.com/repos/sindresorhus/refined-github/languages","stargazers_url":"https://api.github.com/repos/sindresorhus/refined-github/stargazers","contributors_url":"https://api.github.com/repos/sindresorhus/refined-github/contributors","subscribers_url":"https://api.github.com/repos/sindresorhus/refined-github/subscribers","subscription_url":"https://api.github.com/repos/sindresorhus/refined-github/subscription","commits_url":"https://api.github.com/repos/sindresorhus/refined-github/commits{/sha}","git_commits_url":"https://api.github.com/repos/sindresorhus/refined-github/git/commits{/sha}","comments_url":"https://api.github.com/repos/sindresorhus/refined-github/comments{/number}","issue_comment_url":"https://api.github.com/repos/sindresorhus/refined-github/issues/comments{/number}","contents_url":"https://api.github.com/repos/sindresorhus/refined-github/contents/{+path}","compare_url":"https://api.github.com/repos/sindresorhus/refined-github/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sindresorhus/refined-github/merges","archive_url":"https://api.github.com/repos/sindresorhus/refined-github/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sindresorhus/refined-github/downloads","issues_url":"https://api.github.com/repos/sindresorhus/refined-github/issues{/number}","pulls_url":"https://api.github.com/repos/sindresorhus/refined-github/pulls{/number}","milestones_url":"https://api.github.com/repos/sindresorhus/refined-github/milestones{/number}","notifications_url":"https://api.github.com/repos/sindresorhus/refined-github/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sindresorhus/refined-github/labels{/name}","releases_url":"https://api.github.com/repos/sindresorhus/refined-github/releases{/id}","deployments_url":"https://api.github.com/repos/sindresorhus/refined-github/deployments","created_at":"2016-02-15T16:45:02Z","updated_at":"2016-04-06T07:02:10Z","pushed_at":"2016-04-06T12:49:42Z","git_url":"git://github.com/sindresorhus/refined-github.git","ssh_url":"git@github.com:sindresorhus/refined-github.git","clone_url":"https://github.com/sindresorhus/refined-github.git","svn_url":"https://github.com/sindresorhus/refined-github","homepage":"https://chrome.google.com/webstore/detail/refined-github/hlepfoohegkhhmjieoechaddaejaokhf","size":1356,"stargazers_count":575,"watchers_count":575,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":22,"forks":41,"open_issues":22,"watchers":575,"default_branch":"master"}},"base":{"label":"sindresorhus:master","ref":"master","sha":"5da451de571a5b6b1a6849de666c0ccd5a8ed17b","user":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"repo":{"id":51769689,"name":"refined-github","full_name":"sindresorhus/refined-github","owner":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sindresorhus/refined-github","description":"Chrome extension that simplifies the GitHub interface and adds useful features","fork":false,"url":"https://api.github.com/repos/sindresorhus/refined-github","forks_url":"https://api.github.com/repos/sindresorhus/refined-github/forks","keys_url":"https://api.github.com/repos/sindresorhus/refined-github/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sindresorhus/refined-github/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sindresorhus/refined-github/teams","hooks_url":"https://api.github.com/repos/sindresorhus/refined-github/hooks","issue_events_url":"https://api.github.com/repos/sindresorhus/refined-github/issues/events{/number}","events_url":"https://api.github.com/repos/sindresorhus/refined-github/events","assignees_url":"https://api.github.com/repos/sindresorhus/refined-github/assignees{/user}","branches_url":"https://api.github.com/repos/sindresorhus/refined-github/branches{/branch}","tags_url":"https://api.github.com/repos/sindresorhus/refined-github/tags","blobs_url":"https://api.github.com/repos/sindresorhus/refined-github/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sindresorhus/refined-github/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sindresorhus/refined-github/git/refs{/sha}","trees_url":"https://api.github.com/repos/sindresorhus/refined-github/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sindresorhus/refined-github/statuses/{sha}","languages_url":"https://api.github.com/repos/sindresorhus/refined-github/languages","stargazers_url":"https://api.github.com/repos/sindresorhus/refined-github/stargazers","contributors_url":"https://api.github.com/repos/sindresorhus/refined-github/contributors","subscribers_url":"https://api.github.com/repos/sindresorhus/refined-github/subscribers","subscription_url":"https://api.github.com/repos/sindresorhus/refined-github/subscription","commits_url":"https://api.github.com/repos/sindresorhus/refined-github/commits{/sha}","git_commits_url":"https://api.github.com/repos/sindresorhus/refined-github/git/commits{/sha}","comments_url":"https://api.github.com/repos/sindresorhus/refined-github/comments{/number}","issue_comment_url":"https://api.github.com/repos/sindresorhus/refined-github/issues/comments{/number}","contents_url":"https://api.github.com/repos/sindresorhus/refined-github/contents/{+path}","compare_url":"https://api.github.com/repos/sindresorhus/refined-github/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sindresorhus/refined-github/merges","archive_url":"https://api.github.com/repos/sindresorhus/refined-github/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sindresorhus/refined-github/downloads","issues_url":"https://api.github.com/repos/sindresorhus/refined-github/issues{/number}","pulls_url":"https://api.github.com/repos/sindresorhus/refined-github/pulls{/number}","milestones_url":"https://api.github.com/repos/sindresorhus/refined-github/milestones{/number}","notifications_url":"https://api.github.com/repos/sindresorhus/refined-github/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sindresorhus/refined-github/labels{/name}","releases_url":"https://api.github.com/repos/sindresorhus/refined-github/releases{/id}","deployments_url":"https://api.github.com/repos/sindresorhus/refined-github/deployments","created_at":"2016-02-15T16:45:02Z","updated_at":"2016-04-06T07:02:10Z","pushed_at":"2016-04-06T12:49:42Z","git_url":"git://github.com/sindresorhus/refined-github.git","ssh_url":"git@github.com:sindresorhus/refined-github.git","clone_url":"https://github.com/sindresorhus/refined-github.git","svn_url":"https://github.com/sindresorhus/refined-github","homepage":"https://chrome.google.com/webstore/detail/refined-github/hlepfoohegkhhmjieoechaddaejaokhf","size":1356,"stargazers_count":575,"watchers_count":575,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":22,"forks":41,"open_issues":22,"watchers":575,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/refined-github/pulls/145"},"html":{"href":"https://github.com/sindresorhus/refined-github/pull/145"},"issue":{"href":"https://api.github.com/repos/sindresorhus/refined-github/issues/145"},"comments":{"href":"https://api.github.com/repos/sindresorhus/refined-github/issues/145/comments"},"review_comments":{"href":"https://api.github.com/repos/sindresorhus/refined-github/pulls/145/comments"},"review_comment":{"href":"https://api.github.com/repos/sindresorhus/refined-github/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sindresorhus/refined-github/pulls/145/commits"},"statuses":{"href":"https://api.github.com/repos/sindresorhus/refined-github/statuses/be57a4374c499857a1611f256c0ac121afbf4059"}}}}