diff options
author | 2021-02-22 12:22:50 -0600 | |
---|---|---|
committer | 2021-02-22 12:24:32 -0600 | |
commit | ebb23a84559d2526da720bcf4e0aadc082b5d33c (patch) | |
tree | 4d99db85ec3831a198c0f87fb7fdf5a68876fa78 /source/features/clean-repo-filelist-actions.tsx | |
parent | 028d402815e120acbe9665b298b335282878afe7 (diff) | |
download | refined-github-ebb23a84559d2526da720bcf4e0aadc082b5d33c.tar.gz refined-github-ebb23a84559d2526da720bcf4e0aadc082b5d33c.tar.zst refined-github-ebb23a84559d2526da720bcf4e0aadc082b5d33c.zip |
Rename `cleanup-repo-filelist-actions` to `clean-repo-filelist-actions`
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 +}); |