Firefox Developer Edition: 66.0b9 (64-bit)
Mac OS: 10.14.3
I would like to add support for a custom download manager. Meaning, whenever I want to download some file in Firefox, I prefer the download to start in this 3rd-party download manager rather than in default Firefox downloader.
More or less the way it was with FlashGot. Basically, the only reason I want to do this is the fact that FlashGot is not supported in the latest versions of Firefox, apparently.
So far I’ve come up with the following extension of mine:
function handle_onCreated(downloadItem)
{
browser.downloads.cancel(downloadItem.id);
browser.downloads.erase({ id:downloadItem.id });
browser.tabs.update({ url:"mydownloadmanager://".concat(downloadItem.url) });
}
browser.downloads.onCreated.addListener(handle_onCreated);
As you can see, I’m using quite dirty tricks here:
- Wait for a download to start (listen to
onCreated
event); - Immediately cancel the download;
- Remove it from the downloads list;
- Pass the URL to my download manager (
mydownloadmanager://
scheme).
That works just fine, but I am wondering if there is a “cleaner” way, for example some event like downloadIsAboutToStart
or something similar, so I could grab the download URL before the download starts (before the onCreated
event)?
I also find it rather unlikely that I’m the first one to query about this, so perhaps there is already a feature-request in progress?
I found a similar thread, but there the solution/advice was to intercept raw requests and get URL from there, which doesn’t seem to be a good option to me.