From 6d350b8aa4db122751e377215bd14ab3d4fd5b4e Mon Sep 17 00:00:00 2001 From: jchuong Date: Tue, 13 Aug 2024 11:53:24 -0400 Subject: [PATCH] Backport pull request #5910 from jellyfin-web/release-10.9.z Fix "Download All" for Safari Original-merge: 4071c4443757aa01f46398b981f1ccc25615c379 Merged-by: thornbill Backported-by: thornbill --- src/scripts/multiDownload.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/scripts/multiDownload.js b/src/scripts/multiDownload.js index ec3db52015..c9f40f56a4 100644 --- a/src/scripts/multiDownload.js +++ b/src/scripts/multiDownload.js @@ -27,19 +27,11 @@ function fallback(urls) { })(); } -function sameDomain(url) { - const a = document.createElement('a'); - a.href = url; - - return window.location.hostname === a.hostname && window.location.protocol === a.protocol; -} - function download(url) { const a = document.createElement('a'); a.download = ''; a.href = url; - // firefox doesn't support `a.click()`... - a.dispatchEvent(new MouseEvent('click')); + a.click(); } export default function (urls) { @@ -47,19 +39,13 @@ export default function (urls) { throw new Error('`urls` required'); } - if (typeof document.createElement('a').download === 'undefined') { + if (typeof document.createElement('a').download === 'undefined' || browser.iOS) { return fallback(urls); } let delay = 0; urls.forEach(function (url) { - // the download init has to be sequential for firefox if the urls are not on the same domain - if (browser.firefox && !sameDomain(url)) { - setTimeout(download.bind(null, url), 100 * ++delay); - return; - } - - download(url); + setTimeout(download.bind(null, url), 100 * ++delay); }); }