Download Manager - Custom

I am trying implement a download manager using “https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/download” . One of my requirment is users able to download multiple files with single click and don’t force user to select the folder for each file .

I was trying to implement the download the example but it says browser is not defined . how do i get browser object . I am trying plain javascript .

I hope the this going to work on browsers except IE Edge

Where did you write this code? Because the browser object should be defined in just about every webextension context.

Looks thats mistake i made . I thought this was pure java script code .

Do you have any idea how can we implement multi downloads without asking for each download using javascript