简体   繁体   English

chrome 扩展陷阱下载对话框

[英]chrome extension trap download dialog

so on a site that when you hit download, it always asks for a filename when I use a shortcut key to download something - ie it comes up with the "save as" dialog.所以在一个网站上,当你点击下载时,当我使用快捷键下载东西时它总是要求提供文件名 - 即它带有“另存为”对话框。 I want to build a chrome extension to trap that and provide my own filename.我想构建一个 chrome 扩展来捕获它并提供我自己的文件名。

I'm fine with building the extension, I've built lots, but I can't figure out how to trap/inject code into the "save as" dialog.我对构建扩展很好,我已经构建了很多,但我不知道如何将代码捕获/注入到“另存为”对话框中。 [and it generates a dynamic and complicated url that I can't predict, so I can't download from JS] 【并且生成了一个我无法预测的动态复杂的url,所以无法从JS下载】

Is that possible to do?那有可能吗?

I think the answer is "it depends".我认为答案是“视情况而定”。 This page might offer a clue. 这个页面可能会提供一个线索。

If it's an anchor, it looks like a download attribute with a value will be used as the suggested file name.如果它是一个锚点,它看起来像一个带有值的download属性将用作建议的文件名。

But then there is this:但是有这样的:

Note: if the Content-Disposition header has different information from the download attribute, resulting behavior may differ: If the header specifies a filename, it takes priority over a filename specified in the download attribute.注意:如果 Content-Disposition header 具有与下载属性不同的信息,则结果行为可能会有所不同:如果 header 指定文件名,则优先于下载属性中指定的文件名。

It might be possible to fiddle with that.也许可以摆弄它。 Looks like this guy did it on Firefox .看起来这家伙是在 Firefox 上做的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM