| 12 | } |
| 13 | |
| 14 | function linkify(item: HTMLElement): void { |
| 15 | if (item instanceof HTMLAnchorElement) { |
| 16 | // Only PR lists are already linked |
| 17 | item.hash = getHash('pr'); |
| 18 | } else { |
| 19 | // The box hash must be determine by conversation type because (React) issue lists might contain links to PRs too |
| 20 | const conversationLink = $([ |
| 21 | 'a[href*="/issues/"]', |
| 22 | 'a[href*="/pull/"]', |
| 23 | ], closestElement('li', item)); |
| 24 | const url = new URL(conversationLink.href); |
| 25 | const type = pageDetect.isIssue(url) ? 'issue' : 'pr'; |
| 26 | url.hash = getHash(type); |
| 27 | wrapAll(<a href={url.href} className="Link--muted d-flex gap-1" />, ...item.childNodes); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | function init(signal: AbortSignal): void { |
| 32 | observe(commentsCountInLists, linkify, {signal}); |