pouriap / Grabby

A browser extension for downloading files and media from websites
Mozilla Public License 2.0
34 stars 2 forks source link

About using userChrome script to run flashgot.exe directly and adding support for other Download Managers #4

Closed benzBrake closed 1 year ago

benzBrake commented 2 years ago

Currently run flashgot.exe needs to install native host intergention, it's not really suitable for portable version of firefox. Before I found this extenstion I'm using this userChrome script (https://github.com/benzBrake/FirefoxCustomize/blob/master/userChromeJS/downloadPlus/downloadPlus_ff98.uc.js) to send downloads link to thirdparty download manager. This script can add buttons to firefox original download popup window. The Experience of the script is closer to the flashgot extensions on older firefox than DownloadGrab. If I want to download file by firefox, no need to select browse and click save.

https://user-images.githubusercontent.com/11323774/179221956-1943a3b0-43ac-4189-a4d3-1c65721e7d48.mp4

https://user-images.githubusercontent.com/11323774/179221967-77943e7d-d410-4ae3-8946-aefd4540d02b.mp4

And can you adding support for other download managers? https://www.xdown.org/ https://motrix.app/ https://www.filecxx.com/en_US/index.html

If there is anything I can do for you, please notify me.

pouriap commented 2 years ago

The Experience of the script is closer to the flashgot extensions on older firefox than DownloadGrab. If I want to download file by firefox, no need to select browse and click save.

That's nice, I didn't know of that script. But as far as I know recent versions of Firefox don't support Chrome scripts. I'm not sure tho.

In any case it cannot be made into an addon so a lot of users would not be able to use it. I prefer to make this as an addon so average people will be able to use it comfortably.

And can you adding support for other download managers? https://www.xdown.org/ https://motrix.app/ https://www.filecxx.com/en_US/index.html

Sure I'll look into it. Currently I'm changing a lot of things in the addon code and in the native host and in FlashGot.exe so everything is a bit messy and I can't release a new version for a while. I also don't have as much as free time as before. So it's going to take some time.

First I have to finish those changes and then I will try and see if I can add these new download managers.

If there is anything I can do for you, please notify me.

Thanks. I'll tell you if there's anything. I always need testers so if you use this addon and saw any problems feel free to create an issue.

benzBrake commented 2 years ago

But as far as I know recent versions of Firefox don't support Chrome scripts. I'm not sure tho.

userChrome script still working on the latest version on firefox, but it needs to install loader. In principle, as long as firefox still uses js to render the interface, we can run js as we want. There are 2 loader listed as follow: https://github.com/xiaoxiaoflood/firefox-scripts/ https://github.com/MrOtherGuy/fx-autoconfig/

pouriap commented 2 years ago

That's very interesting.

It has file access and can run executables so it's possible to use flashgot.exe with this. I'll look more into it and see if I can quickly integrate flashgot.

Did you write the downloadPlus script yourself?

benzBrake commented 2 years ago

Did you write the downloadPlus script yourself? The downloadPlus script not written by myself, This script can not work since firefox98, I pick it up and rewrite some codes of it.

pouriap commented 2 years ago

I tried your downloadPlus_ff98.uc.js with Firefox 90 and it doesn't seem to work. And I get an error in the console that seems to be complaining about the version.

Does the version have to be exactly 98?

benzBrake commented 2 years ago

Does the version have to be exactly 98?

Fixed for firefox 78~98 just now, please update the script

pouriap commented 2 years ago

I still see the old download dialog.

It doesn't matter tho, you can do it yourself if you know javascript. Flashgot.exe gets a filename as input. That file tells flashgot what download manager it should use and all the other information it needs. The structure of the file is as follows:

{number-of-downloads};{download-manager-name};0;;
{referer}
{download-url}
{description}
{cookies}
{post-data}
{filename}
{file-extension}
{download-page-referer}
{download-page-cookies}
blank line
blank line
{user-agent}

Don't include the curly brackets I just put them for visual purposes. In case any of this information does not exist leave it blank. The download manager name should be exactly the name that flashgot expects. To see the list of download managers run flashgot.exe with no arguments from command line.

So for example for downloading firefox the file would look like this:

1;Internet Download Manager;0;;
https://www.mozilla.org/
https://download-installer.cdn.mozilla.net/pub/devedition/releases/103.0b9/win64/en-US/Firefox%20Setup%20103.0b9.exe
Firefox Setup 103.0b9.exe

Firefox Setup 103.0b9.exe
exe
https://www.mozilla.org/en-US/firefox/new/
cookie=something

Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0

This download doesn't have any HTTP POST data or cookies so those fields are simply left empty.

Now all you have to do is save this file with any name, like dl.txt, and then run flashgot like flashgot.exe dl.txt and then it will run your selected download manager.

It should be fairly easy to do since your script already has all this information and can create files and run programs.

siamak2 commented 2 years ago

@pouriap thank you for writing about how to work with flashgot.exe. I really couldn't figure out how to work with it when I was submitting https://github.com/pouriap/Firefox-DownloadGrab/pull/1 PR. Now with your explanation and downloadPlus I might be able to merge these two and finally get the experience of the good old flashgot add-on.

I have two questions:

  1. Can you tell me how to get list of installed download managers from flashgot.exe?
  2. How to write multiple links in the text file?
benzBrake commented 2 years ago

@siamak2

Can you tell me how to get list of installed download managers from flashgot.exe?

Flashgot.exe -o dm.txt

benzBrake commented 2 years ago

@pouriap

demo script is here: https://gist.github.com/benzBrake/83fd3f054c8b31f59d2ee2f0cf9226d9

The next few days I have to travel with my family. Work will be continued in the next week. Or may be you can finish the script if you can. @siamak2

Default path for flashgot.exe is {profileDir}\chrome\resources\tools\FlashGot.exe, and you can't custom flashgot path by acout:config, set userChromeJS.downloadPlus.flashgotPath to your flashgot path

https://user-images.githubusercontent.com/11323774/179916356-5fec6728-9d5f-4fcb-9ccc-52be382e8af0.mp4

siamak2 commented 2 years ago

@benzBrake nice work on the gist. but I have something else in my mind. I want it to be exactly like the flashgot add-on. That means I want to add one row above save file to choose download manager. Right now this script is creating a wide download dialog which I don't like. Do you want it to be wide?

in line 101 you need to replace Services.prefss.get with Services.prefs.getStringPref to make prefs work. I think it's better to create a repository rather than gist.

pouriap commented 2 years ago
2. How to write multiple links in the text file?
{number-of-downloads};{download-manager-name};0;;
{referer}
    {download-url}
    {description}
    {cookies}
    {post-data}
    {filename}
    {file-extension}
{download-page-referer}
{download-page-cookies}
blank line
blank line
{user-agent}

Repeat the indented section for each download you have, and also put the number of downloads in the first placeholder {number-of-downloads} (You don't have to actually indent it, I just did that to emphasize that section)

But be aware that if you are in private browsing your downloads will be written to a file and can be read by other programs. If I recall correctly flashgot actually shredded the file when you were in private browsing, and that 0 in the file template actually tells it if it's a private download or not.

I intend to update flashgot.exe and make it so that it accepts a JSON formatted file as input, making it easier to understand and create from javascript code. I will also make sure to handle links from private browsing properly. So stay tuned for updates.

benzBrake commented 2 years ago

@siamak2

Do you want it to be wide?

Nope. I just make the function work with minimal code changes. The latest version switches to original flashgot style.

downloadPlus_ff98

@pouriap I have pushed the lastest version of downloadPlus_ff98.uc.js https://github.com/benzBrake/FirefoxCustomize/blob/master/userChromeJS/downloadPlus/downloadPlus_ff98.uc.js