分享

用其他浏览器打开当前链接- Open URL With.uc.js

 舟客 2011-10-26
自己修改,用ie和chrome,打开,作改时地址改成\\
、、、、、、、、、、、、、、、、、

/* Open URL With
* nanto_vi (TOYAMA Nao), 2006-12-26
*
* Open an application with the current page's URL.
*/

(function OpenURLWith() {
    
    const MENU_LABEL = "Open With";
    const MENU_ACCESSKEY = "O";
    
    const IE_PATH = "C:\\Program Files\\Internet Explorer\\iexplore.exe";
    const chrome_PATH = "C:\\Documents and Settings\\Administrator\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe";
    
    var mMenus = [
        {
            label: "Internet Explorer(link)",
            accesskey: "L",
            application: IE_PATH,
            get url() { return gContextMenu.linkURL; },
            get shouldDisplay() { return gContextMenu.onLink; }
        },
        {
            label: " chrome (link)",
            accesskey: "N",
            application: chrome_PATH,
            get url() { return gContextMenu.linkURL; },
            get shouldDisplay() { return gContextMenu.onLink; }
        },
        {
            label: "-",
            get shouldDisplay() { return gContextMenu.onLink; }
        },
        {
            label: "Internet Explorer(page)",
            accesskey: "I",
            application: IE_PATH,
            get url() { return content.location.href; },
        },
        {
            label: " chrome(page)",
            accesskey: "O",
            application: chrome_PATH,
            get url() { return content.location.href; },
        },
        {
            label: "-",
            get shouldDisplay() { return gContextMenu.inFrame; }
        },
        {
            label: "Internet Explorer",
            accesskey: "F",
            application: IE_PATH,
            get url() { return document.commandDispatcher.focusedWindow.location.href; },
            get shouldDisplay() { return gContextMenu.inFrame; }
        },
        {
            label: " chrome",
            accesskey: "R",
            application: chrome_PATH,
            get url() { return document.commandDispatcher.focusedWindow.location.href; },
            get shouldDisplay() { return gContextMenu.inFrame; }
        }
    ];
    
    init: {
        let parentMenu = document.createElement("menu");
        parentMenu.setAttribute("label", MENU_LABEL);
        if (typeof MENU_ACCESSKEY != "undefined" && MENU_ACCESSKEY)
            parentMenu.setAttribute("accesskey", MENU_ACCESSKEY);
        document.getElementById("contentAreaContextMenu").insertBefore(
            parentMenu, document.getElementById("context-sep-properties"));
        
        let parentPopup = document.createElement("menupopup");
        parentPopup.id = "openurlwith-popup";
        parentPopup.addEventListener("command", openApplication, false);
        parentMenu.appendChild(parentPopup);
        
        for (let i = 0, menu; menu = mMenus[i]; i++) {
            let menuItem;
            if (menu.label == "-") {
                menuItem = document.createElement("menuseparator");
            } else {
            menuItem = document.createElement("menuitem");
            menuItem.setAttribute("label", menu.label);
            if ("accesskey" in menu)
                menuItem.setAttribute("accesskey", menu.accesskey);
            menuItem.ouwMenu = menu;
        }
        parentPopup.appendChild(menuItem);
    }
    
    parentMenu.parentNode.addEventListener("popupshowing", setMenuDisplay, false);
}

function openApplication(aEvent) {
    var menu = aEvent.target.ouwMenu;
    
    var app = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
    app.initWithPath(menu.application);
    if (!app.exists()) {
        alert("File doesn't exist: " + menu.application);
        return;
    }
    
    Cc["@mozilla.org/browser/shell-service;1"]
    .getService(Ci.nsIShellService_MOZILLA_1_8_BRANCH || Ci.nsIShellService)
    .openApplicationWithURI(app, menu.url);
}

function setMenuDisplay() {
    var menuItems = document.getElementById("openurlwith-popup").childNodes;
    for (var i = 0, menu; menu = mMenus[i]; i++)
        menuItems[i].hidden = "shouldDisplay" in menu && !menu.shouldDisplay;
}

})();

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多