| 39 | } |
| 40 | |
| 41 | function 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 | |
| 55 | async function init(signal: AbortSignal): Promise<void> { |
| 56 | observe('div[class*="file-path-section"]', maybeAddIcon, {signal}); |