MCPcopy
hub / github.com/refined-github/refined-github / getParticipants

Function getParticipants

source/features/reactions-avatars.tsx:25–63  ·  view source on GitHub ↗
(button: HTMLButtonElement)

Source from the content-addressed store, hash-verified

23};
24
25function getParticipants(button: HTMLButtonElement): Participant[] {
26 let users;
27
28 if (button.getAttribute('role') === 'switch') { // [aria-label] alone is not a differentiator
29 users = button.nextElementSibling!
30 .textContent
31 .replace(/^.+including /, '')
32 .replace(/\)/, '')
33 .replace(/,? and /, ', ')
34 .replace(/, \d+ more/, '')
35 .split(', ');
36 // Uses optional chaining to throw an error manually later
37 } else if (button.nextElementSibling?.tagName === 'TOOL-TIP') {
38 // The list of people who commented is in an adjacent `<tool-tip>` element #5698
39 users = button.nextElementSibling
40 .textContent
41 .replace(/ reacted with.*/, '')
42 .replace(/,? and /, ', ')
43 .replace(/, \d+ more/, '')
44 .split(', ');
45 } else {
46 throw new Error('Unknown reaction button layout');
47 }
48
49 const currentUser = getLoggedInUser();
50 const participants = [];
51 for (const username of users) {
52 if (username === currentUser) {
53 continue;
54 }
55
56 const imageUrl = getUserAvatar(username, avatarSize);
57 if (imageUrl) {
58 participants.push({button, username, imageUrl});
59 }
60 }
61
62 return participants;
63}
64
65function showAvatarsOn(reactionsContainer: Element): void {
66 const reactions = $$optional([

Callers 1

showAvatarsOnFunction · 0.85

Calls 2

getUserAvatarFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected