Firefox 扩展:处理文件保存对话框

发布于 2024-11-02 09:26:11 字数 943 浏览 3 评论 0原文

我访问的一些网页具有顽固的可执行文件保存文件对话框。我想使用扩展名执行以下操作之一:

  1. 默认保存文件并关闭对话框。我查看了 http://kb.mozillazine.org/File_types_and_download_actions 它对这些文件不起作用(问题描述见:http://kb.mozillazine.org/File_types_and_download_actions 下的“无法设置”自动操作。我验证了标题。)

    如果我弄清楚第一部分,我想我可以使用 https://developer.mozilla.org/en/Download_Manager_preferences 中的 browser.download.manager.closeWhenDone :)

  2. 抑制下载管理器完全不显示任何此类对话框。

我发现 https://developer.mozilla.org/en/nsIDownloadManager#addListener() 和 https://developer.mozilla.org/en/Download_Manager_improvements_in_Firefox_3 看起来很有希望。我也不知道如何提取传输的源 URI。我很好奇是否有人有任何使用这些的现有示例,或者是否有更好的方法来做到这一点。或者如果有人知道我可以查看 Firefox 代码的哪一部分,那也会很有用。

谢谢!

PS:抱歉,我不得不在 https:// 之后使用不必要的空格来破坏上面的超链接 - 显然我需要 10 个声誉才能做到这一点:)

Some of the webpages I visit have stubborn save file dialogs for executables. I would like to do one of the following using an extension:

  1. Save the file by default and close the dialog box. I looked at http://kb.mozillazine.org/File_types_and_download_actions It doesn't really work for these files (the problem is described at: http://kb.mozillazine.org/File_types_and_download_actions under 'Unable to set automatic action. I verified the headers.)

    I guess I can use browser.download.manager.closeWhenDone from https:// developer.mozilla.org/en/Download_Manager_preferences , if I figure out the first part :)

  2. Suppress the download manager from showing any such dialogs altogether.

I found https:// developer.mozilla.org/en/nsIDownloadManager#addListener() and https:// developer.mozilla.org/en/Download_Manager_improvements_in_Firefox_3 that look promising. I don't really know how to extract the source URI for the transfer either. I'm curious if anyone has any existing examples for using these or if there's a better way to do this. Or if someone knows what part of Firefox's code I could poke, that would be useful too.

Thanks!

PS: Sorry,I had to break the hyper-links above with an unnecessary space after https:// - apparently I need 10 reputation to do that :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

·深蓝 2024-11-09 09:26:11

FWIW,我设法解决了这个问题 - 尽管我的解决方案可能不适用于大多数其他人。

幸运的是,我在我控制的代理后面,所以我只是在令人讨厌的标头(Content-Disposition 和 Content-Type)到达 Firefox 之前更正了它们。尽管我指定了“始终保存此类型的文件”,但这些都迫使 Firefox 打开“文件保存”对话框。此外,我将“browser.download.manager.closeWhenDone”属性设置为 True。对我有用,我浏览这些网站不会被打扰。

FWIW, I managed to work around this - though my solution probably wont work for most others.

Fortunately I'm behind a proxy I control, so I just corrected the obnoxious headers (Content-Disposition and Content-Type) before they reached Firefox. These were forcing Firefox to open the File Save Dialog box despite my specified preference to 'Always save file of this type'. Furthermore, I set 'browser.download.manager.closeWhenDone' property to True. Works for me, and I cruise through such sites w.o being interrupted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文