diff --git a/src/btn.ts b/src/btn.ts index 844b611..9b009db 100644 --- a/src/btn.ts +++ b/src/btn.ts @@ -105,12 +105,12 @@ export namespace BtnAction { }) } - export const download = (url: UrlInput, filename?: string): BtnAction => { + export const download = (url: UrlInput): BtnAction => { return process(async (): Promise => { const _url = await normalizeUrlInput(url) - const r = await fetch(_url) - const blob = await r.blob() - saveAs(blob, filename) + const a = document.createElement('a') + a.href = _url + a.dispatchEvent(new MouseEvent('click')) }) } diff --git a/src/main.ts b/src/main.ts index 8b63e82..edc3d7c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -42,13 +42,13 @@ const main = (): void => { btnList.add({ name: 'Download MIDI', action: BtnAction.deprecate( - BtnAction.download(() => getFileUrl('midi'), `${filename}.mid`), + BtnAction.download(() => getFileUrl('midi')), ), }) btnList.add({ name: 'Download MP3', - action: BtnAction.download(() => getFileUrl('mp3'), `${filename}.mp3`), + action: BtnAction.download(() => getFileUrl('mp3')), }) btnList.add({