How do I change a filename on-download with javascript?

后端 未结 6 1196
心在旅途
心在旅途 2021-02-02 16:03

The script adds a download link for videos (on a specific site). How do I change the filename to something else while downloading?

Example URL:
\"http://websit         


        
6条回答
  •  长情又很酷
    2021-02-02 16:55

    You can probably do this with a Chrome userscript, but it cannot be done (yet) with Greasemonkey (Firefox) javascript.

    Workaround methods (easiest to hardest):

    1. Add the links with Greasemonkey but use the excellent DownThemAll! add-on to download and rename the videos.

    2. Download the videos as-is and use a batch file, shell-script, Python program, etc. to rename them.

    3. Use Greasemonkey's GM_xmlhttpRequest()Doc function to send the files to your own web application on a server you control.
      This server could be your own PC running XAMPP (or similar).

    4. Write your own Firefox add-on, instead of a Greasemonkey script. Add-ons have the required privileges, Greasemonkey does not.

提交回复
热议问题