Chrome Build: the newest, 33+
A Chrome Extension extracts certain urls from currently viewed site and then downloads a subset of them (quite often hundreds of files).
Expected Behavior:
Files are downloaded into the default Download-Folder without questioning where and under which filename they have to be saved.
Problem:
If a user has enabled the option "Ask where to save each file before downloading" in Chrome->Settings->Advanced Settings->Downloads then when trying to download, for example, 100 files simultaniously, Chrome tries to open 100 SaveAs Dialogs and crashes.
What I tried:
using the following code to trigger a download through an emulated mousevent:
function saveAs(Url,filename){
var blob=new Blob([''], {type:'application/octet-stream'});
var url = webkitURL.createObjectURL(blob);
var a = document.createElementNS('http://www.w3.org/1999/xhtml','a');
a.href = Url;
a.download = filename;
var e = document.createEvent('MouseEvents');
e.initMouseEvent('click', false, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(e);
webkitURL.revokeObjectURL(url);
}
In the future, if you want to disable the “Save As” prompt in Google Chrome, turn off the toggle beside the “Ask where to save each file before downloading” option.
Step 1: Open the Chrome menu (click the icon with three dots to the upper-right corner of the window), and then click Settings. Step 2: Expand the Advanced section, and then click Downloads. Step 3: Under the Downloads group, click Clear next to 'Open certain file types automatically after downloading. '
It is impossible when "Ask where to save each file before downloading" Enabled (as of 70.0.3538.77). The corresponding Chromium bug is:
Bug 417112: chrome.downloads.download ignore saveAs
Moreover setting filename in chrome.downloads.downloads()
also doesn't work.
Bug 758094: Extension can not rename downloaded file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With