From 8de091f4dd7eec7a79788fe1c6d1c323e8592774 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 15 Apr 2023 14:51:27 +0800 Subject: [PATCH] Work around Chrome download limit Closes #18775. --- src/webui/www/private/scripts/misc.js | 7 +++++++ src/webui/www/private/scripts/mocha-init.js | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/webui/www/private/scripts/misc.js b/src/webui/www/private/scripts/misc.js index 0c5685f0c..618d6fec1 100644 --- a/src/webui/www/private/scripts/misc.js +++ b/src/webui/www/private/scripts/misc.js @@ -44,6 +44,7 @@ window.qBittorrent.Misc = (function() { safeTrim: safeTrim, toFixedPointString: toFixedPointString, containsAllTerms: containsAllTerms, + sleep: sleep, MAX_ETA: 8640000 }; }; @@ -218,6 +219,12 @@ window.qBittorrent.Misc = (function() { }); }; + const sleep = (ms) => { + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); + }; + return exports(); })(); diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index 87748bf85..d07c10519 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -958,7 +958,7 @@ const initializeWindows = function() { return torrentsTable.selectedRowsIds().join("\n"); }; - exportTorrentFN = function() { + exportTorrentFN = async function() { const hashes = torrentsTable.selectedRowsIds(); for (const hash of hashes) { const row = torrentsTable.rows.get(hash); @@ -976,6 +976,9 @@ const initializeWindows = function() { document.body.appendChild(element); element.click(); document.body.removeChild(element); + + // https://stackoverflow.com/questions/53560991/automatic-file-downloads-limited-to-10-files-on-chrome-browser + await window.qBittorrent.Misc.sleep(200); } };