|
阅读:8148回复:19
可以代替firegestures扩展的脚本是哪一个?
如题,高手指点下,是GM脚本还是UC脚本?
|
|
|
1楼#
发布于:2010-01-09 17:13
Firegestures手势里本来就有关闭窗口
|
|
|
2楼#
发布于:2010-01-09 17:13
|
|
|
3楼#
发布于:2010-01-09 17:13
Firegestures手势里本来就有关闭窗口。 |
|
|
|
4楼#
发布于:2010-01-09 17:13
我试了下配合next page(0.1.7.3)完全可以实现的 你用UL,UR不行是不是手势有冲突,这两个手势原来的脚本里已经有预设了,是不是没有去掉 |
|
|
5楼#
发布于:2010-01-09 17:13
|
|
|
6楼#
发布于:2010-01-09 17:13
这个我试了下,发现Next page脚本的手势命令虽然有,但我改不了,比方说我想改成“UL”是向上一页,“UR”是向下一页,可不起作用,有些晕。 |
|
|
7楼#
发布于:2010-01-09 17:13
|
|
|
8楼#
发布于:2010-01-09 17:13
扩展不是挺好的 ?嗯为什么都要用js替代?扩展也就是js+UI大包吧。千万不要被“软件”玩。
我以前也是专门搜集脚本,后来发现,“误入狼穴”了…… |
|
|
9楼#
发布于:2010-01-09 17:13
|
|
|
10楼#
发布于:2010-01-09 17:13
Ericks 引用的时候适当删减嘛,全引再加上那么长的签名档,占好多空间啊。
Xelnaga 真是够耐心,值得学习! |
|
|
|
11楼#
发布于:2010-01-09 17:13
隔壁不是有个很全的手势脚本嘛,还带中文说明的。我现在还用的firegestures,但是添加的新手势几乎都是从那个脚本里找的
|
|
|
12楼#
发布于:2010-01-09 17:13
xelnaga:本质上,扩展对功能的实现靠的也是JS 十分感谢热心帮忙,我这里只改了一个返加上一页,没想到您帮忙全给改过来了,万分感谢哈! |
|
|
13楼#
发布于:2010-01-09 17:13
受益匪浅;
原来还能这样用。 |
|
|
14楼#
发布于:2010-01-09 17:13
本质上,扩展对功能的实现靠的也是JS
包括FX本身也是在靠JS实现功能 对于自己实现一些功能来说,纯脚本确实简单一些,只要专注在脚本功能实现上就行了。不过对用户而言,脚本的可配置型没有扩展高,并不是所有人能看懂JS的,即使是一些简单的语句,甚至有人对简单的英文也不明白。所以还是推荐扩展,说到这个,我想我也明白了为什么MOZILLA没有直接集成UC自定义JS脚本这个功能。 这个有点题外话了 讲正题 如果你需要什么功能可以去firegestures里的js文件找 路径在firegestures.xpi/chrome/firegestures.jar/browser.js 上面贴的这个Mouse Gestures (Lite Version) ,它对操作的实现基本上依靠浏览器自己已经实现的部分 Firegestures这个扩展则在浏览器之外自己实现了更多功能 当然都是用js写的 所以你需要什么功能可以去firegestures里的browser.js文件里去找它的实现方法 如果是firegestures自己实现的,你就拷贝它的代码,如果是fx自身已经实现的,你也可以找到它的方法怎么写 比如你需要go upper level功能 browser.js里面去找 upper 字段,可以找到 goUpperLevel: function() {
var uri = gBrowser.currentURI;
if (uri.path == "/")
return;
var pathList = uri.path.split("/");
if (!pathList.pop())
pathList.pop();
loadURI(uri.prePath + pathList.join("/") + "/");
},你可以把它拷贝到mouse gesture的代码里 添加相应的识别/执行代码 // go upper level
case "L": this.goUpperLevel(); break;--------------------------------------------------- 重启浏览器的代码是: case "L": Application.restart(); break; 关闭窗口是 case "L": window.close(); break; -------------------------- 以下是完整的,添加了返回上一级、关闭、重启功能的代码 添加部分做了分割线 // ==UserScript==
// @name Mouse Gestures (Lite Version)
// @namespace http://www.xuldev.org/
// @description Lightweight customizable mouse gestures.
// @include main
// @compatibility Firefox 3.0, 3.5, 3.6b4
// @author Gomita
// @version 1.0.20080201
// @homepage http://www.xuldev.org/misc/ucjs.php
// ==/UserScript==
var ucjsMouseGestures = {
_lastX: 0,
_lastY: 0,
_directionChain: "",
init: function()
{
gBrowser.mPanelContainer.addEventListener("mousedown", this, false);
gBrowser.mPanelContainer.addEventListener("mousemove", this, false);
gBrowser.mPanelContainer.addEventListener("mouseup", this, false);
gBrowser.mPanelContainer.addEventListener("contextmenu", this, true);
},
uninit: function()
{
gBrowser.mPanelContainer.removeEventListener("mousedown", this, false);
gBrowser.mPanelContainer.removeEventListener("mousemove", this, false);
gBrowser.mPanelContainer.removeEventListener("mouseup", this, false);
gBrowser.mPanelContainer.removeEventListener("contextmenu", this, true);
},
_isMouseDown: false,
_suppressContext: false,
_shouldFireContext: false, // for Linux
handleEvent: function(event)
{
switch (event.type) {
case "mousedown":
if (event.button == 2) {
this._isMouseDown = true;
this._startGesture(event);
}
break;
case "mousemove":
if (this._isMouseDown) {
this._progressGesture(event);
}
break;
case "mouseup":
if (this._isMouseDown) {
this._isMouseDown = false;
this._suppressContext = !!this._directionChain;
this._stopGesture(event);
if (this._shouldFireContext) {
this._shouldFireContext = false;
this._displayContextMenu(event);
}
}
break;
case "contextmenu":
if (this._suppressContext || this._isMouseDown) {
this._suppressContext = false;
event.preventDefault();
event.stopPropagation();
if (this._isMouseDown) {
this._shouldFireContext = true;
}
}
break;
}
},
_displayContextMenu: function(event)
{
var evt = event.originalTarget.ownerDocument.createEvent("MouseEvents");
evt.initMouseEvent(
"contextmenu", true, true, event.originalTarget.defaultView, 0,
event.screenX, event.screenY, event.clientX, event.clientY,
false, false, false, false, 2, null
);
event.originalTarget.dispatchEvent(evt);
},
_startGesture: function(event)
{
this._lastX = event.screenX;
this._lastY = event.screenY;
this._directionChain = "";
},
_progressGesture: function(event)
{
var x = event.screenX;
var y = event.screenY;
var distanceX = Math.abs(x - this._lastX);
var distanceY = Math.abs(y - this._lastY);
// minimal movement where the gesture is recognized
const tolerance = 10;
if (distanceX < tolerance && distanceY < tolerance)
return;
// determine current direction
var direction;
if (distanceX > distanceY)
direction = x < this._lastX ? "L" : "R";
else
direction = y < this._lastY ? "U" : "D";
// compare to last direction
var lastDirection = this._directionChain.charAt(this._directionChain.length - 1);
if (direction != lastDirection) {
this._directionChain += direction;
XULBrowserWindow.statusTextField.label = "Gesture: " + this._directionChain;
}
// save current position
this._lastX = x;
this._lastY = y;
},
_stopGesture: function(event)
{
try {
if (this._directionChain)
this._performAction(event);
XULBrowserWindow.statusTextField.label = "";
}
catch(ex) {
XULBrowserWindow.statusTextField.label = ex;
}
this._directionChain = "";
},
// ============================ 添加部分============================
goUpperLevel: function() {
var uri = gBrowser.currentURI;
if (uri.path == "/")
return;
var pathList = uri.path.split("/");
if (!pathList.pop())
pathList.pop();
loadURI(uri.prePath + pathList.join("/") + "/");
},
_performAction: function(event)
{
// These are the mouse gesture mappings. Customize this as you like.
switch (this._directionChain) {
// go upper level
case "LRL": this.goUpperLevel(); break;
// close window
case "RLR": window.close(); break;
// restart firefox
case "LRLR": Application.restart(); break;
// ============================ 添加部分============================
// Back
case "L": document.getElementById("Browser:Back").doCommand(); break;
// Forward
case "R": document.getElementById("Browser:Forward").doCommand(); break;
// Reload
case "UD": document.getElementById("Browser:Reload").doCommand(); break;
// Reload (Skip Cache)
case "UDU": document.getElementById("Browser:ReloadSkipCache").doCommand(); break;
// Minimize Window
case "RUD": window.minimize(); break;
// Maximize Window or Restore Window Size
case "RDU": window.windowState == 1 ? window.restore() : window.maximize(); break;
// Open New Tab
case "LR": document.getElementById("cmd_newNavigatorTab").doCommand(); break;
// Close Tab
case "DR": document.getElementById("cmd_close").doCommand(); break;
// Undo Close Tab
case "DL": document.getElementById("History:UndoCloseTab").doCommand(); break;
// Undo Close Tab (If you are using Tab Mix Plus's Session Manager, use this instead.)
// case "DL": gBrowser.undoRemoveTab(); break;
// Previous Tab
case "UL": gBrowser.mTabContainer.advanceSelectedTab(-1, true); break;
// Next Tab
case "UR": gBrowser.mTabContainer.advanceSelectedTab(+1, true); break;
// Scroll Top
case "LU": goDoCommand("cmd_scrollTop"); break;
// Scroll Bottom
case "LD": goDoCommand("cmd_scrollBottom"); break;
// Page Up
case "U": goDoCommand("cmd_scrollPageUp"); break;
// Page Down
case "D": goDoCommand("cmd_scrollPageDown"); break;
// Increase Text Size
case "LRD": document.getElementById("cmd_textZoomReduce").doCommand(); break;
// Decrease Text Size
case "LRU": document.getElementById("cmd_textZoomEnlarge").doCommand(); break;
// Full Screen
case "LDRU": document.getElementById("View:FullScreen").doCommand(); break;
// Unknown Gesture
default: throw "Unknown Gesture: " + this._directionChain;
}
}
};
// Entry Point
ucjsMouseGestures.init();
window.addEventListener("unload", function(){ ucjsMouseGestures.uninit(); }, false); |
|
上一页
下一页
