| 23 | ]; |
| 24 | |
| 25 | export function shortenLink(link: HTMLAnchorElement): void { |
| 26 | // Exclude the link if the closest element found is not `.markdown-body` |
| 27 | // This avoids shortening links in code and code suggestions, but still shortens them in review comments |
| 28 | // https://github.com/refined-github/refined-github/pull/4759#discussion_r702460890 |
| 29 | if (!closestElementOptional([...codeElementsSelector, '.markdown-body'], link)?.classList.contains('markdown-body')) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | applyToLink(link, location.href); |
| 34 | |
| 35 | // Customize same-thread links. Already handled by GitHub, but badly |
| 36 | // https://github.com/refined-github/refined-github/issues/6057 |
| 37 | switch (link.textContent) { |
| 38 | case `#${getConversationNumber()} (comment)`: { |
| 39 | link.textContent = '(earlier comment)'; |
| 40 | break; |
| 41 | } |
| 42 | |
| 43 | case `#${getConversationNumber()} (review)`: { |
| 44 | link.textContent = '(earlier review)'; |
| 45 | break; |
| 46 | } |
| 47 | |
| 48 | default: |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // https://github.com/refined-github/refined-github/issues/6336#issuecomment-1498645639 |
| 53 | export function repositionAnchors(element: HTMLElement): void { |