MCPcopy Index your code
hub / github.com/refined-github/refined-github / shortenLink

Function shortenLink

source/github-helpers/dom-formatters.tsx:25–50  ·  view source on GitHub ↗
(link: HTMLAnchorElement)

Source from the content-addressed store, hash-verified

23];
24
25export 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
53export function repositionAnchors(element: HTMLElement): void {

Callers 1

shortenLinksInFragmentFunction · 0.85

Calls 1

getConversationNumberFunction · 0.85

Tested by 1

shortenLinksInFragmentFunction · 0.68