15楼#
发布于:2020-07-17 21:04
|
|
16楼#
发布于:2020-03-19 14:26
|
|
17楼#
发布于:2020-03-19 13:12
kidzgy:我发现了个问题,就是通过直接保存到桌面,文件名会莫名出现如图左边这样: 我这里无法重现,会自动将非法字符删掉的。 试试将 file.initWithPath(path + (document.querySelector("#locationtext") ? document.querySelector("#locationtext").value : document.querySelector("#location").value));替换成 file.initWithPath(path + (document.querySelector("#locationtext") ? document.querySelector("#locationtext").value : document.querySelector("#location").value).trim()); |
|
18楼#
发布于:2020-03-19 01:04
lonely_8:“保存到”按钮的下拉菜单?翻遍了脚本也只有这里出现绝对路径。我发现了个问题,就是通过直接保存到桌面,文件名会莫名出现如图左边这样: 图片:QQ截图20200319005730.png 右边的图呢,就是不通过【保存到】这个按钮,而是通过先按下确定,然后自行选择路径保存。 奇怪的是,保存到桌面的,如果将这个文件剪切到另外一个位置,文件名是跟平时保存时一样的。但是,如果在同一路径下,使用【保存到】桌面和普通保存,两个文件竟然可以共存,明明就是同一个文件名啊! 后来发现,不单单是桌面,即便是保存到其他位置,实际上文件名前面多了个空格。而当重命名时,即便删除掉了这个空格,系统会提示你文件名已存在。 猜想:本身因为脚本的缘故,会对文件名开头添加一个空格,如果按照平时的保存方式,系统会过滤掉空格,但如果直接通过保存到的当时,则没有过滤掉这个空格。 测试链接:https://www.lanzous.com/i9uiauh |
|
19楼#
发布于:2020-03-06 22:25
|
|
20楼#
发布于:2020-03-02 20:56
|
|
21楼#
发布于:2020-03-02 19:35
cambriancn:你好,我有另一个调动第三方下载的增强脚本,看看能否修正? 代码见 帖子回复回到原帖 // ==UserScript== // @name downloadPlus.uc.js // @description 下载窗口添加:另存为、双击复制链接、第三方工具下载 // @include chrome://mozapps/content/downloads/unknownContentType.xhtml // @version 2019.09.28 // @startup window.MDownloadPlus.init(); // @note 双击直接下载 by 52think // @note 新增链接类型不支持提示,新增第三方应用调用参数 by Ryan Lieu<github-benzBrake@woai.ru> // @note 适配Firefox57+ // ==/UserScript== (function () { const PREF_BD_USEDOWNLOADDIR = "browser.download.useDownloadDir"; const dialogElement = document.documentElement.getButton ? document.documentElement : document.getElementById('unknownContentType'); let config = { defaultActionToSave:true,//默认选择下载文件 addSaveAsButton:true,//添加另存为按钮,只在选择了默认保存位置时添加 copySourceByDbClick:true,//来源显示完整目录并支持双击复制完整地址 useExtraAppDownload:true,//使用第三方下载工具下载 directDownloadByDbClick:true, //双击直接下载 /* IDM示例 */ extraAppName:"IDM",//下载工具名称 extraAppPath:"C:\\Program\ Files\\Idm\\IDMan.exe", //下载工具路径 extraAppParameter:"/d pw_url",//下载工具参数 /* 迅雷示例 */ // extraAppName:"迅雷",//下载工具名称 // extraAppPath:"C:\\Program\ Files\\Thunder\\Program\\Thunder.exe", //下载工具路径 // extraAppParameter: "/pw_url",//下载工具参数 _:false }; var downloadModule = {}; Components.utils.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule); Components.utils.import("resource://gre/modules/Downloads.jsm"); var MDownloadPlus = { createExtraAppButton:function () { let btn = dialogElement.getButton("extra2"); if(btn){ btn.setAttribute("hidden", "false"); btn.setAttribute("label", config.extraAppName); btn.setAttribute("oncommand", 'window.MDownloadPlus.lauchExtraApp();') } }, lauchExtraApp:function () { let url = dialog.mLauncher.source.spec; let regEx = new RegExp("^data"); if (regEx.test(url)) { alert("此类链接不支持调用第三方工具下载"); return; } parameter = config.extraAppParameter.replace("pw_url", url); let extraApp = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile); extraApp.initWithPath(config.extraAppPath); if (!extraApp.exists()) { alert(config.extraAppName+ "不存在: " + config.extraAppPath); return; } let p = Components.classes["@mozilla.org/process/util;1"] .createInstance(Components.interfaces.nsIProcess); let commandArgs = parameter.split(" "); p.init(extraApp); p.run(false, commandArgs, commandArgs.length); dialog.mDialog.dialog = null; window.close(); }, createSaveAsButton(){ let prefs = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); let autodownload = prefs.getBoolPref(PREF_BD_USEDOWNLOADDIR, false); if(autodownload){ var btn = dialogElement.getButton("extra1"); if(btn){ btn.setAttribute("hidden", "false"); btn.setAttribute("label", "另存为"); btn.setAttribute("oncommand", 'window.MDownloadPlus.saveAs();'); } } }, saveAs:function () { var modeGroup = dialog.dialogElement("mode"); modeGroup.selectedItem = dialog.dialogElement("save"); var mainWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser"); mainWindow.eval("(" + mainWindow.internalSave.toString().replace("let ", "").replace("var fpParams", "fileInfo.fileExt=null;fileInfo.fileName=aDefaultFileName;var fpParams") + ")")(dialog.mLauncher.source.asciiSpec, null, (document.querySelector("#locationtext") ? document.querySelector("#locationtext").value : dialog.mLauncher.suggestedFileName), null, null, null, null, null, null, mainWindow.document, 0, null); close(); }, directDownloadByDbClick:function () { addEventListener("dblclick", function(event) { event.target.nodeName === "radio" && dialogElement.getButton("accept").click(); }, false); }, copySourceByDbClick:function () { var source = document.querySelector("#source"); source.value = dialog.mSourcePath; source.setAttribute("crop", "center"); source.setAttribute("tooltiptext", dialog.mLauncher.source.spec); source.setAttribute("ondblclick", 'Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper).copyString(dialog.mLauncher.source.spec)'); }, init:function () { if(config.defaultActionToSave){ var modeGroup = dialog.dialogElement("mode"); modeGroup.selectedItem = dialog.dialogElement("save"); } if(config.addSaveAsButton){ this.createSaveAsButton(); } if(config.directDownloadByDbClick) { this.directDownloadByDbClick(); } if(config.copySourceByDbClick){ this.copySourceByDbClick(); } if(config.useExtraAppDownload){ this.createExtraAppButton(); } } } function isUsableDirectory(aDirectory) { return aDirectory.exists() && aDirectory.isDirectory() && aDirectory.isWritable(); } if (location.href.startsWith("chrome://mozapps/content/downloads/unknownContentType.x")) { MDownloadPlus.init(); window.MDownloadPlus = MDownloadPlus; } })() |
|
22楼#
发布于:2020-03-02 18:08
|
|
23楼#
发布于:2020-03-02 14:55
@lonely_8
这个版本的下载增强脚本,能否也帮忙修改一下,支持 调用 idm 第三方的 // ==UserScript== // @name downloadPlus.uc.js // @description 下载窗口添加:另存为、双击复制链接、第三方工具下载 // @include chrome://mozapps/content/downloads/unknownContentType.xul // @version 2019.09.28 // @startup window.MDownloadPlus.init(); // @note 双击直接下载 by 52think // @note 新增链接类型不支持提示,新增第三方应用调用参数 by Ryan Lieu<github-benzBrake@woai.ru> // @note 适配Firefox57+ // ==/UserScript== (function () { const PREF_BD_USEDOWNLOADDIR = "browser.download.useDownloadDir"; let config = { defaultActionToSave:true,//默认选择下载文件 addSaveAsButton:true,//添加另存为按钮,只在选择了默认保存位置时添加 copySourceByDbClick:true,//来源显示完整目录并支持双击复制完整地址 useExtraAppDownload:true,//使用第三方下载工具下载 directDownloadByDbClick:true, //双击直接下载 /* IDM示例 */ extraAppName:"IDM",//下载工具名称 extraAppPath:"C:\\Program\ Files\\Idm\\IDMan.exe", //下载工具路径 extraAppParameter:"/d pw_url",//下载工具参数 /* 迅雷示例 */ // extraAppName:"迅雷",//下载工具名称 // extraAppPath:"C:\\Program\ Files\\Thunder\\Program\\Thunder.exe", //下载工具路径 // extraAppParameter: "/pw_url",//下载工具参数 _:false }; var downloadModule = {}; Components.utils.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule); Components.utils.import("resource://gre/modules/Downloads.jsm"); var MDownloadPlus = { createExtraAppButton:function () { let btn = dialog.mDialog.document.documentElement.getButton("extra2"); if(btn){ btn.setAttribute("hidden", "false"); btn.setAttribute("label", config.extraAppName); btn.setAttribute("oncommand", 'window.MDownloadPlus.lauchExtraApp();') } }, lauchExtraApp:function () { let url = dialog.mLauncher.source.spec; let regEx = new RegExp("^data"); if (regEx.test(url)) { alert("此类链接不支持调用第三方工具下载"); return; } parameter = config.extraAppParameter.replace("pw_url", url); let extraApp = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile); extraApp.initWithPath(config.extraAppPath); if (!extraApp.exists()) { alert(config.extraAppName+ "不存在: " + config.extraAppPath); return; } let p = Components.classes["@mozilla.org/process/util;1"] .createInstance(Components.interfaces.nsIProcess); let commandArgs = parameter.split(" "); p.init(extraApp); p.run(false, commandArgs, commandArgs.length); dialog.mDialog.dialog = null; window.close(); }, createSaveAsButton(){ let prefs = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); let autodownload = prefs.getBoolPref(PREF_BD_USEDOWNLOADDIR, false); if(autodownload){ var btn = dialog.mDialog.document.documentElement.getButton("extra1"); if(btn){ btn.setAttribute("hidden", "false"); btn.setAttribute("label", "另存为"); btn.setAttribute("oncommand", 'window.MDownloadPlus.saveAs();'); } } }, saveAs:function () { var modeGroup = dialog.dialogElement("mode"); modeGroup.selectedItem = dialog.dialogElement("save"); var mainWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser"); mainWindow.eval("(" + mainWindow.internalSave.toString().replace("let ", "").replace("var fpParams", "fileInfo.fileExt=null;fileInfo.fileName=aDefaultFileName;var fpParams") + ")")(dialog.mLauncher.source.asciiSpec, null, (document.querySelector("#locationtext") ? document.querySelector("#locationtext").value : dialog.mLauncher.suggestedFileName), null, null, null, null, null, null, mainWindow.document, 0, null); close(); }, directDownloadByDbClick:function () { addEventListener("dblclick", function(event) { event.target.nodeName === "radio" && document.documentElement.getButton("accept").click(); }, false); }, copySourceByDbClick:function () { var source = document.querySelector("#source"); source.value = dialog.mSourcePath; source.setAttribute("crop", "center"); source.setAttribute("tooltiptext", dialog.mLauncher.source.spec); source.setAttribute("ondblclick", 'Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper).copyString(dialog.mLauncher.source.spec)'); }, init:function () { if(config.defaultActionToSave){ var modeGroup = dialog.dialogElement("mode"); modeGroup.selectedItem = dialog.dialogElement("save"); } if(config.addSaveAsButton){ this.createSaveAsButton(); } if(config.directDownloadByDbClick) { this.directDownloadByDbClick(); } if(config.copySourceByDbClick){ this.copySourceByDbClick(); } if(config.useExtraAppDownload){ this.createExtraAppButton(); } } } function isUsableDirectory(aDirectory) { return aDirectory.exists() && aDirectory.isDirectory() && aDirectory.isWritable(); } if (location.href.startsWith("chrome://mozapps/content/downloads/unknownContentType.x")) { MDownloadPlus.init(); window.MDownloadPlus = MDownloadPlus; } })() |
|
24楼#
发布于:2020-02-20 01:16
|
|
25楼#
发布于:2020-02-19 23:10
|
|
26楼#
发布于:2020-02-19 21:53
|
|
27楼#
发布于:2020-02-19 00:40
kidzgy:大佬您好!https://www.firefox.net.cn/read-121355 关于downloadplus还有两个问题需要修复。一个是自动关闭空白标签页,另外一个是下载框文件名改名,这两个都有点问题。您看能修复吗?谢谢!回到原帖第一个问题在1楼原楼层尝试修复了。 第二个我用72和73测试都没发现问题。 |
|
28楼#
发布于:2020-02-18 21:38
lonely_8:原楼层已经改好了。回到原帖大佬您好!https://www.firefox.net.cn/read-121355 关于downloadplus还有两个问题需要修复。一个是自动关闭空白标签页,另外一个是下载框文件名改名,这两个都有点问题。您看能修复吗?谢谢! |
|
29楼#
发布于:2020-02-12 21:49
谢谢,原来又用回之前的方法了。
|
|
|