pizzak
小狐狸
小狐狸
  • UID31706
  • 注册日期2010-01-22
  • 最后登录2014-06-11
  • 发帖数4
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
阅读:1988回复:3

URL SUFFIX不好用啊

楼主#
更多 发布于:2010-01-24 20:22
我设置alt+enter 为 www. .cn, 可是使用时却出现个另存为的窗口。

我设置shift+enter 为 www. .net,可是使用时却蹦出个新的窗口,而不是新的标签。

请问该怎么设置?
just4fun
千年狐狸
千年狐狸
  • UID30408
  • 注册日期2009-09-17
  • 最后登录2016-04-28
  • 发帖数1497
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度2点
1楼#
发布于:2010-01-24 20:22
之前用URL Suffix - Continued 0.4.4 是OK的,现在用ucjs脚本,别的都正常,就是alt相关项会在后台新建标签页打开

// ==UserScript==
// @name           URL Suffix
// @namespace      http://www.quchao.com/
// @description    Adding suffix to url by pressing different keys.
// @include        main
// @compatibility  Firefox 2.0.* 3.6a1pre
// @author         Qu Chao (Chappell.Wat) <Chappell.Wat@Gmail.com>
// @version        1.0
// @Note
// ==/UserScript==
// Released under the GPL license
//  http://www.gnu.org/copyleft/gpl.html
// Appreciate to
//  Gomyoung Kim (http://heygom.com/extensions/)
// ver 1.0 @ 2008-7-17
//  Initialize release

(function() {
	var UrlSuffix = function () {
		const canonizeUrl = function (aTriggeringEvent) {
				var url = this.value;
				if (!url) {
					return ["", null];
				}
				if (!/\x20/.test(url) && !/^(www|http|chrome|ftp|https)|\/\s*$/i.test(url) && aTriggeringEvent instanceof KeyEvent) {
					let accel = aTriggeringEvent.ctrlKey;
					let shift = aTriggeringEvent.shiftKey;
					let alt = aTriggeringEvent.altKey;
					let suffix = "";
					switch (true) {
					  case accel && shift && alt:
						suffix = ".org.cn/";
						break;
					  case accel && shift:
						suffix = ".com.cn/";
						break;
					  case accel && alt:
						suffix = ".cn/";
						break;
					  case shift && alt:
						suffix = ".org/";
						break;
					  case shift:
						suffix = ".net/";
						break;
					  case alt:
						suffix = ".cn/";
						break;
					  case accel:
						try {
							suffix = gPrefService.getCharPref("browser.fixup.alternate.suffix");
							if (suffix.charAt(suffix.length - 1) != "/") {
								suffix += "/";
							}
						} catch (e) {
							suffix = ".com/";
						}
						break;
					  default:;
					}
					if (suffix) {
						url = url.trim();
						let firstSlash = url.indexOf("/");
						let existingSuffix = url.indexOf(suffix.substring(0, suffix.length - 1));
						if (firstSlash >= 0) {
							if (existingSuffix == -1 || existingSuffix > firstSlash) {
								url = url.substring(0, firstSlash) + suffix + url.substring(firstSlash + 1);
							}
						} else {
							url = url + (existingSuffix == -1 ? suffix : "/");
						}
						url = "http://www." + url;
					}
				}
				var postData = {};
				url = getShortcutOrURI(url, postData);
				return [url, postData.value];
			};
		return {
			init: function () {
				gURLBar._canonizeURL = canonizeUrl;
			}
		};
	}();
	UrlSuffix.init();
})();
pizzak
小狐狸
小狐狸
  • UID31706
  • 注册日期2010-01-22
  • 最后登录2014-06-11
  • 发帖数4
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
2楼#
发布于:2010-01-24 20:22
谢谢楼上提供的代码,可是我装上后还是没变化啊
just4fun
千年狐狸
千年狐狸
  • UID30408
  • 注册日期2009-09-17
  • 最后登录2016-04-28
  • 发帖数1497
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度2点
3楼#
发布于:2010-01-24 20:22
要先装userChromeJS并且让它可用,然后把上述代码另存为“文件名.uc.js”。具体怎么弄在隔壁有教程
游客

返回顶部