fooxx
小狐狸
小狐狸
  • UID36314
  • 注册日期2011-05-21
  • 最后登录2013-09-17
  • 发帖数68
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
阅读:1773回复:2

如何把这个调用IE打开的UC脚本改为调用多个浏览器打开

楼主#
更多 发布于:2012-08-21 15:46
如图

图片:sshot-1.png



// ==UserScript==
// @name         View in other browser
// @include      main
// @author       Cye3s
// @version      1.0.20100715
// ==/UserScript==
var LaunchBrowser = {
	browserName:"TheWorld",
	browserPath:"D:\\Program Files\\TheWorld3\\TheWorld.exe",
	mSchemes: ["file", "ftp", "http", "https"],
	browser: Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile),
	shellServicr:Cc["@mozilla.org/browser/shell-service;1"].getService(Ci.nsIShellService),
	init: function()
	{
		this.initialized = true;
		var menuLabel = "\u5728"+this.browserName+"\u4E2D\u6253\u5F00";
		this.browser.initWithPath(this.browserPath);
		this.mItem = document.createElement("menuitem");
		this.mItem.setAttribute("id", "context-LaunchBrowser");
		this.mItem.setAttribute("label", menuLabel);
		this.mItem.setAttribute("accesskey", "U");
		this.mItemPlace = document.createElement("menuitem");
		this.mItemPlace.setAttribute("id", "placesContext-LaunchBrowser");
		this.mItemPlace.setAttribute("label", menuLabel);
		this.mItemPlace.setAttribute("accesskey", "U");
		this.mItemPlace.setAttribute("selection","link");
		this.mItemPlace.setAttribute("selectiontype","single");
		document.getElementById("contentAreaContextMenu").addEventListener("popupshowing", function() { LaunchBrowser.onPopupShowing(this); }, false);
		document.getElementById("placesContext").addEventListener("popupshowing", function() { LaunchBrowser.onPopupShowingPlace(); }, false);
		document.getElementById("sidebar-box").addEventListener("load", function(event) {
			var doc = event.target;
			if (doc.location == "chrome://browser/content/history/history-panel.xul"||doc.location == "chrome://browser/content/bookmarks/bookmarksPanel.xul") {
				var context = doc.getElementById("placesContext");
				context.addEventListener("popupshowing", function() {
					window.parent.LaunchBrowser.mItemPlace.setAttribute("oncommand", "try {var LaunchBrowserSideBar=window.parent.LaunchBrowser;var node=document.popupNode;node = node.parentNode.view.nodeForTreeIndex(node.parentNode.view.selection.currentIndex);LaunchBrowserSideBar.shellServicr.openApplicationWithURI(LaunchBrowserSideBar.browser,node.uri);} catch (ex) { alert(ex.message);}");
					context.insertBefore(window.parent.LaunchBrowser.mItemPlace,doc.getElementById("placesContext_open:newwindow"));
				}, false);
			}
		}, true);
		
		this.mItemTab = document.createElement("menuitem");
		this.mItemTab.setAttribute("id", "tab-context-LaunchBrowser");
		this.mItemTab.setAttribute("label", menuLabel);
		this.mItemTab.setAttribute("accesskey", "U");
		this.mItemTab.setAttribute("oncommand", "LaunchBrowser.launch(gBrowser.getBrowserForTab(document.popupNode).currentURI);");
		gBrowser.mStrip.childNodes[1].appendChild(this.mItemTab);

	},
	onPopupShowing: function(aPopup)
	{
		aPopup.insertBefore(this.mItem, document.getElementById("context-sep-" + ((gContextMenu.onLink)?"open":"stop")));
		this.mItem.setAttribute("oncommand", "LaunchBrowser.launch(" + ((gContextMenu.onLink)?"gContextMenu.linkURI":"gBrowser.currentURI") + ");");
		this.mItem.hidden = !gContextMenu.onLink && (gContextMenu.isTextSelected || gContextMenu.onImage || gContextMenu.onTextInput);
		this.mItem.setAttribute("disabled", this.mItem.hidden || !this.isSupported((gContextMenu.onLink)?gContextMenu.linkURI:gBrowser.currentURI));
	},
	onPopupShowingPlace: function()
	{
		this.mItemPlace.setAttribute("oncommand", "LaunchBrowser.placesLaunch();");
		document.getElementById("placesContext").insertBefore(this.mItemPlace,document.getElementById("placesContext_open:newtab"));
	},
	launch: function(aURI)
	{
		if (!this.isSupported(aURI))
		{
			throw new Error("LaunchBrowser: unsupported URI scheme '" + aURI.scheme + "'!");
		}
		this.shellServicr.openApplicationWithURI(this.browser,aURI.spec);
	},
	isSupported: function(aURI)
	{
		return this.mSchemes.indexOf(aURI.scheme) > -1;
	},
	placesLaunch: function()
	{
		var n = document.popupNode;
		if (n.node && n.node.uri)
		{
			this.shellServicr.openApplicationWithURI(this.browser,n.node.uri);
		}
		else if (n._placesNode && n._placesNode.uri)
		{
			this.shellServicr.openApplicationWithURI(this.browser,n._placesNode.uri);
		}
	}
};
LaunchBrowser.init();
附件名称/大小 下载次数 最后更新
ViewInOtherBrowser.uc.zip (2KB)  25 2012-08-21 15:47
fooxx
小狐狸
小狐狸
  • UID36314
  • 注册日期2011-05-21
  • 最后登录2013-09-17
  • 发帖数68
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
1楼#
发布于:2012-08-21 15:46
发错区了,请版主移动一下,谢谢诶
taglife
千年狐狸
千年狐狸
  • UID38488
  • 注册日期2012-03-20
  • 最后登录2013-04-02
  • 发帖数2052
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度1点
2楼#
发布于:2012-08-21 15:46
browserName:"TheWorld",
   browserPath:"D:\\Program Files\\TheWorld3\\TheWorld.exe",
Firefox 開啟安全模式,停用個人設定、佈景主題及擴充套件(無附加元件)測試:
說明 > 重新啟動但停用附加元件(Firefox 4+)
Firefox Profile: 說明 > 疑難排解資訊 > 開啟資料夾
排版引擎:Firefox(Gecko), Opera(Presto), Google Chrome(WebKit),
Safari(WebKit), Internet Explorer(Trident), Konqueror(KHTML)
游客

返回顶部