diff options
Diffstat (limited to 'source/features/clean-repo-filelist-actions.tsx')
-rw-r--r-- | source/features/clean-repo-filelist-actions.tsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/features/clean-repo-filelist-actions.tsx b/source/features/clean-repo-filelist-actions.tsx new file mode 100644 index 00000000..01849493 --- /dev/null +++ b/source/features/clean-repo-filelist-actions.tsx @@ -0,0 +1,41 @@ +import React from 'dom-chef'; +import select from 'select-dom'; +import * as pageDetect from 'github-url-detection'; +import {PlusIcon, SearchIcon} from '@primer/octicons-react'; + +import features from '.'; + +function init(): void { + const searchButton = select('.btn[data-hotkey="t"]')!; + searchButton.classList.add('tooltipped', 'tooltipped-ne'); + searchButton.setAttribute('aria-label', 'Go to file'); + searchButton.firstChild!.replaceWith(<SearchIcon/>); + + const addButtonWrapper = searchButton.nextElementSibling!; + if (addButtonWrapper.nodeName === 'DETAILS') { + addButtonWrapper.classList.add('tooltipped', 'tooltipped-ne'); + addButtonWrapper.setAttribute('aria-label', 'Add file'); + + const addIcon = select('.btn span', addButtonWrapper)!; + addIcon.classList.replace('d-md-flex', 'd-md-block'); + addIcon.firstChild!.replaceWith(<PlusIcon/>); + } + + const downloadButton = select('get-repo details'); + if (downloadButton) { + downloadButton.classList.add('tooltipped', 'tooltipped-ne'); + downloadButton.setAttribute('aria-label', 'Clone or download'); + select('.octicon-download', downloadButton)!.nextSibling!.remove(); + } +} + +void features.add(__filebasename, { + include: [ + pageDetect.isRepoTree, + pageDetect.isSingleFile + ], + exclude: [ + pageDetect.isEmptyRepo + ], + init +}); |