From ebb23a84559d2526da720bcf4e0aadc082b5d33c Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Mon, 22 Feb 2021 12:22:50 -0600 Subject: Rename `cleanup-repo-filelist-actions` to `clean-repo-filelist-actions` --- source/features/clean-repo-filelist-actions.tsx | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 source/features/clean-repo-filelist-actions.tsx (limited to 'source/features/clean-repo-filelist-actions.tsx') 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(); + + 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(); + } + + 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 +}); -- cgit v1.2.3