Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore download-folder-button on new file list UI #6705

Merged
merged 3 commits into from
Jun 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions source/features/download-folder-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';

function add(folderDropdown: HTMLElement): void {
function addLegacy(folderDropdown: HTMLElement): void {
const downloadUrl = new URL('https://download-directory.github.io/');
downloadUrl.searchParams.set('url', location.href);

Expand All @@ -22,11 +22,22 @@
);
}

function add({parentElement: deleteDirectoryItem}: HTMLAnchorElement): void {
const item = deleteDirectoryItem!.cloneNode(true);
const link = item.firstElementChild as HTMLAnchorElement;
const downloadUrl = new URL('https://download-directory.github.io/');
downloadUrl.searchParams.set('url', location.href);
link.href = downloadUrl.href;
link.textContent = 'Download directory';

deleteDirectoryItem!.before(item);
}

function init(signal: AbortSignal): void {
observe([
'[title="More options"]',
'[aria-label="Add file"] + details', // TODO: Drop in mid 2023. Old file view #6154
], add, {signal});
observe('a[aria-keyshortcuts="d"]', add, {signal});

// TODO: Drop in late 2023. Old file view #6154
observe('[aria-label="Add file"] + details', addLegacy, {signal});
}

void features.add(import.meta.url, {
Expand All @@ -47,4 +58,4 @@
- Own repo: https://github.com/refined-github/refined-github/tree/main/.github
- Archived repo: https://github.com/fregante/object-fit-images/tree/master/demo

*/

Check notice on line 61 in source/features/download-folder-button.tsx

View workflow job for this annotation

GitHub Actions / TestURLs