Javascript Greasemonkey-“;另存为;对话屏幕
我正在尝试制作一个greasemonkey用户脚本,它将弹出浏览器/操作系统针对某个文件的“另存为对话框” 因此,预期的结果将是:Javascript Greasemonkey-“;另存为;对话屏幕,javascript,save,greasemonkey,Javascript,Save,Greasemonkey,我正在尝试制作一个greasemonkey用户脚本,它将弹出浏览器/操作系统针对某个文件的“另存为对话框” 因此,预期的结果将是: var link = 'http://www.example.com/example.jpeg'; //or .zip or .doc or whatever popout link(link); //This should make the specified link be available in the "save as dialogue" 我尝试了以下
var link = 'http://www.example.com/example.jpeg'; //or .zip or .doc or whatever
popout link(link); //This should make the specified link be available in the "save as dialogue"
我尝试了以下代码,我发现:
但不幸的是,这没有起作用。我在网上到处都找不到答案,我搜索了好几个小时:(
如果Greasemonkey不事先询问就将文件保存到文件夹中也可以,但这是不可能的,因为我到处都读过。因此,一个日志窗口仍然是一个可接受的解决方案,这样用户只需单击每个文件的“确定”
我知道也可以推送到服务器,让服务器下载给定的文件,但我不寻找这样的解决方案
编辑:还发现它确实有一个SaveLocal api/函数。我只要使用它就可以了。但是我已经尝试过将它作为zip文件下载,重命名为.xpi,然后手动安装为Firefox插件。没有乐趣,有人知道如何安装它吗?你的Greasemonkey脚本可以在主机页中创建一个html链接(document.createElement('a')等),最近引入了下载属性,如下所述:
var link = 'http://www.example.com/example.jpeg';
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
link.dispatchEvent(clickEvent);