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

后端 未结 6 1187
心在旅途
心在旅途 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:38

    Just in case you are looking for such a solution for your nasty downloading chrome extension, you should look into chrome.downloads API, it needs additional permission ('downloads') and allows you to specify filename. https://developer.chrome.com/extensions/downloads

    However there is a problem I'm facing right now. The chrome extension I'm refactoring has 600k+ user base and adding a new permission would disable the extension for all of them. So it is no-go solution for me, but if you are developing a new extension you definitely should use it.

提交回复
热议问题