kidzgy
火狐狸
火狐狸
  • UID35190
  • 注册日期2011-02-03
  • 最后登录2024-03-28
  • 发帖数248
  • 经验196枚
  • 威望0点
  • 贡献值122点
  • 好评度17点
15楼#
发布于:2020-07-17 21:04
kidzgy:完美!感谢大神!回到原帖
大神你好!现在FF78,【保存到】这个功能失效了,能修复吗?
kidzgy
火狐狸
火狐狸
  • UID35190
  • 注册日期2011-02-03
  • 最后登录2024-03-28
  • 发帖数248
  • 经验196枚
  • 威望0点
  • 贡献值122点
  • 好评度17点
16楼#
发布于:2020-03-19 14:26
lonely_8:我这里无法重现,会自动将非法字符删掉的。
试试将
file.initWithPath(path + (document.querySelector("#locationtext") ? document.querySelector("#...
回到原帖
完美!感谢大神!
lonely_8
非常火狐
非常火狐
  • UID30273
  • 注册日期2009-09-03
  • 最后登录2022-08-09
  • 发帖数733
  • 经验469枚
  • 威望0点
  • 贡献值86点
  • 好评度147点
  • 社区居民
  • 忠实会员
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());
kidzgy
火狐狸
火狐狸
  • UID35190
  • 注册日期2011-02-03
  • 最后登录2024-03-28
  • 发帖数248
  • 经验196枚
  • 威望0点
  • 贡献值122点
  • 好评度17点
18楼#
发布于:2020-03-19 01:04
lonely_8:“保存到”按钮的下拉菜单?翻遍了脚本也只有这里出现绝对路径。
如果是的话,可以这样
,
回到原帖
我发现了个问题,就是通过直接保存到桌面,文件名会莫名出现如图左边这样:

图片:QQ截图20200319005730.png


右边的图呢,就是不通过【保存到】这个按钮,而是通过先按下确定,然后自行选择路径保存。


奇怪的是,保存到桌面的,如果将这个文件剪切到另外一个位置,文件名是跟平时保存时一样的。但是,如果在同一路径下,使用【保存到】桌面和普通保存,两个文件竟然可以共存,明明就是同一个文件名啊!



后来发现,不单单是桌面,即便是保存到其他位置,实际上文件名前面多了个空格。而当重命名时,即便删除掉了这个空格,系统会提示你文件名已存在。


猜想:本身因为脚本的缘故,会对文件名开头添加一个空格,如果按照平时的保存方式,系统会过滤掉空格,但如果直接通过保存到的当时,则没有过滤掉这个空格。

测试链接:https://www.lanzous.com/i9uiauh
brightspray
小狐狸
小狐狸
  • UID56119
  • 注册日期2017-11-20
  • 最后登录2020-12-25
  • 发帖数3
  • 经验5枚
  • 威望0点
  • 贡献值8点
  • 好评度2点
19楼#
发布于:2020-03-06 22:25
etjim:1.将config.js放在firefox的安装目录下;
2.将config-prefs.js放在“安装目录\defaults\pref”里;
3.将userChrome.js放在“配置文件夹\chrome”里,注意此userChrom...
回到原帖
UC
cambriancn
小狐狸
小狐狸
  • UID57310
  • 注册日期2019-10-10
  • 最后登录2022-10-05
  • 发帖数28
  • 经验30枚
  • 威望0点
  • 贡献值16点
  • 好评度1点
20楼#
发布于:2020-03-02 20:56
lonely_8:// ==UserScript==
// @name        downloadPlus.uc.js
// @description 下载窗口添加:另存为、双击复制链接、第三方工具下载
// @include     chrome...
回到原帖
牛,review的好快;改的内容也不少啊
lonely_8
非常火狐
非常火狐
  • UID30273
  • 注册日期2009-09-03
  • 最后登录2022-08-09
  • 发帖数733
  • 经验469枚
  • 威望0点
  • 贡献值86点
  • 好评度147点
  • 社区居民
  • 忠实会员
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;
    }
})()
cambriancn
小狐狸
小狐狸
  • UID57310
  • 注册日期2019-10-10
  • 最后登录2022-10-05
  • 发帖数28
  • 经验30枚
  • 威望0点
  • 贡献值16点
  • 好评度1点
22楼#
发布于:2020-03-02 18:08
lonely_8:我这里没问题。回到原帖
你好,我有另一个调动第三方下载的增强脚本,看看能否修正? 代码见 帖子回复
cambriancn
小狐狸
小狐狸
  • UID57310
  • 注册日期2019-10-10
  • 最后登录2022-10-05
  • 发帖数28
  • 经验30枚
  • 威望0点
  • 贡献值16点
  • 好评度1点
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;
    }
})()
kidzgy
火狐狸
火狐狸
  • UID35190
  • 注册日期2011-02-03
  • 最后登录2024-03-28
  • 发帖数248
  • 经验196枚
  • 威望0点
  • 贡献值122点
  • 好评度17点
24楼#
发布于:2020-02-20 01:16
lonely_8:“保存到”按钮的下拉菜单?翻遍了脚本也只有这里出现绝对路径。
如果是的话,可以这样
,
回到原帖
哦对就是保存到,没错,就是这样的效果,真真牛逼!谢谢!
lonely_8
非常火狐
非常火狐
  • UID30273
  • 注册日期2009-09-03
  • 最后登录2022-08-09
  • 发帖数733
  • 经验469枚
  • 威望0点
  • 贡献值86点
  • 好评度147点
  • 社区居民
  • 忠实会员
25楼#
发布于:2020-02-19 23:10
kidzgy:原来如此,已经默默修复了!感谢感谢!没见你说出来还以为没修复,我还以为别人也没察觉呢。
对了,在使用的时候发现一新的建议,就是另存为那里,看脚本设置的都是绝对路径,不知道UC脚本有没有办法获取注册表里桌面的路径(因为每台电脑桌面路径都不一样...
回到原帖
“保存到”按钮的下拉菜单?翻遍了脚本也只有这里出现绝对路径。
如果是的话,可以这样
[Services.dirsvc.get('Desk', Ci.nsIFile).path, "桌面"],
kidzgy
火狐狸
火狐狸
  • UID35190
  • 注册日期2011-02-03
  • 最后登录2024-03-28
  • 发帖数248
  • 经验196枚
  • 威望0点
  • 贡献值122点
  • 好评度17点
26楼#
发布于:2020-02-19 21:53
lonely_8:第一个问题在1楼原楼层尝试修复了。
第二个我用72和73测试都没发现问题。
回到原帖
原来如此,已经默默修复了!感谢感谢!没见你说出来还以为没修复,我还以为别人也没察觉呢。
对了,在使用的时候发现一新的建议,就是另存为那里,看脚本设置的都是绝对路径,不知道UC脚本有没有办法获取注册表里桌面的路径(因为每台电脑桌面路径都不一样),这样我设置一个另存为【桌面】,无论在哪台电脑使用,都肯定是保存在桌面的了。
就是UC脚本能不能获取注册表值是个问题。
lonely_8
非常火狐
非常火狐
  • UID30273
  • 注册日期2009-09-03
  • 最后登录2022-08-09
  • 发帖数733
  • 经验469枚
  • 威望0点
  • 贡献值86点
  • 好评度147点
  • 社区居民
  • 忠实会员
27楼#
发布于:2020-02-19 00:40
kidzgy:大佬您好!https://www.firefox.net.cn/read-121355 关于downloadplus还有两个问题需要修复。一个是自动关闭空白标签页,另外一个是下载框文件名改名,这两个都有点问题。您看能修复吗?谢谢!回到原帖
第一个问题在1楼原楼层尝试修复了。
第二个我用72和73测试都没发现问题。
kidzgy
火狐狸
火狐狸
  • UID35190
  • 注册日期2011-02-03
  • 最后登录2024-03-28
  • 发帖数248
  • 经验196枚
  • 威望0点
  • 贡献值122点
  • 好评度17点
28楼#
发布于:2020-02-18 21:38
lonely_8:原楼层已经改好了。回到原帖
大佬您好!https://www.firefox.net.cn/read-121355 关于downloadplus还有两个问题需要修复。一个是自动关闭空白标签页,另外一个是下载框文件名改名,这两个都有点问题。您看能修复吗?谢谢!
withero
小狐狸
小狐狸
  • UID37110
  • 注册日期2011-08-29
  • 最后登录2024-05-05
  • 发帖数45
  • 经验64枚
  • 威望0点
  • 贡献值14点
  • 好评度0点
  • 社区居民
29楼#
发布于:2020-02-12 21:49
谢谢,原来又用回之前的方法了。
www.helup.com
游客

返回顶部