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

Function maybeAddIcon

source/features/new-or-deleted-file.tsx:41–53  ·  view source on GitHub ↗
(fileHeader: HTMLDivElement)

Source from the content-addressed store, hash-verified

39}
40
41function maybeAddIcon(fileHeader: HTMLDivElement): void {
42 const fileLink = $('a', fileHeader);
43 const listIcon = $(`li[class*="file-tree-row"]:has(a[href="${fileLink.hash}"]) ` + is(iconSelectors));
44 if (listIcon.classList.contains('octicon-file-diff')) {
45 // We only select the icon to avoid $optional
46 return;
47 }
48
49 const icon = listIcon.cloneNode(true);
50 // Undo `display: none` that might be added by extensions like "Material Icons for GitHub"
51 icon.style.display = '';
52 fileHeader.append(<div className="d-flex ml-1 tmp-ml-1">{icon}</div>);
53}
54
55async function init(signal: AbortSignal): Promise<void> {
56 observe('div[class*="file-path-section"]', maybeAddIcon, {signal});

Callers

nothing calls this directly

Calls 3

isFunction · 0.85
cloneNodeMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected