mmd
mmd
禁止发言
禁止发言
  • UID52039
  • 注册日期2015-12-16
  • 最后登录2016-12-02
  • 发帖数539
  • 经验549枚
  • 威望0点
  • 贡献值758点
  • 好评度26点
阅读:1215回复:4

如何实现小书签重启火狐浏览器

楼主#
更多 发布于:2016-08-21 15:35
用户被禁言,该主题自动屏蔽!
mmd
mmd
禁止发言
禁止发言
  • UID52039
  • 注册日期2015-12-16
  • 最后登录2016-12-02
  • 发帖数539
  • 经验549枚
  • 威望0点
  • 贡献值758点
  • 好评度26点
1楼#
发布于:2016-08-21 15:37
用户被禁言,该主题自动屏蔽!
fang5566
管理员
管理员
  • UID3719
  • 注册日期2005-03-07
  • 最后登录2024-04-29
  • 发帖数18483
  • 经验4837枚
  • 威望5点
  • 贡献值4316点
  • 好评度1116点
  • 社区居民
  • 最爱沙发
  • 忠实会员
  • 终身成就
2楼#
发布于:2016-08-21 15:57
bookmarklet只能识别JavaScript:打头的脚本代码,这种是不行的。要用uc扩展脚本来实现。
Firefox More than meets your experience
mmd
mmd
禁止发言
禁止发言
  • UID52039
  • 注册日期2015-12-16
  • 最后登录2016-12-02
  • 发帖数539
  • 经验549枚
  • 威望0点
  • 贡献值758点
  • 好评度26点
3楼#
发布于:2016-08-21 16:06
用户被禁言,该主题自动屏蔽!
shenmo
小狐狸
小狐狸
  • UID33580
  • 注册日期2010-07-30
  • 最后登录2022-12-29
  • 发帖数77
  • 经验68枚
  • 威望0点
  • 贡献值28点
  • 好评度1点
4楼#
发布于:2016-08-21 19:34
我用的uc脚本,鼠标手势DL,重启浏览器


// ==UserScript==
// @name           MouseGestures.uc.js
// @include        chrome://browser/content/browser.xul
// @compatibility  Firefox 3.0.x
// ==/UserScript==

location == "chrome://browser/content/browser.xul" && (function () {
ucjsMouseGestures = {
lastX: 0,
lastY: 0,
sourceNode: "",
directionChain: "",
isMouseDownL: false,
isMouseDownR: false,
hideFireContext: false,
shouldFireContext: false,
GESTURES: {
//转到页首
"U": {
name: "\u8f6c\u5230\u9875\u9996",
cmd: function() {
goDoCommand("cmd_scrollTop");
}
},
//转到页尾
"D": {
name: "\u8f6c\u5230\u9875\u5c3e",
cmd: function() {
goDoCommand("cmd_scrollBottom");
}
},
//后退
"L": {
name: "\u540e\u9000",
cmd: function() {
getWebNavigation().canGoBack && getWebNavigation().goBack();
}
},
//前进
"R": {
name: "\u524d\u8fdb",
cmd: function() {
getWebNavigation().canGoForward && getWebNavigation().goForward();
}
},
//删除启动缓存并重启
"DL": {
name: "\u5220\u9664\u542f\u52a8\u7f13\u5b58\u5e76\u91cd\u542f",
cmd: function() {
Services.appinfo.invalidateCachesOnRestart() || BrowserUtils.restartApplication();
}
},
//关闭当前标签
"DR": {
name: "\u5173\u95ed\u5f53\u524d\u6807\u7b7e",
cmd: function() {
gBrowser.removeCurrentTab();
}
},
            //打开Chrome目录
"LR": {
name: "\u6253\u5f00Chrome\u76ee\u5f55",
cmd: function() {
Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("UChrm", Components.interfaces.nsILocalFile).reveal();
}
},
},
init: function () {
var self = this;
["mousedown", "mousemove", "mouseup", "contextmenu", "DOMMouseScroll", "dragend"].forEach(function (type) {
gBrowser.mPanelContainer.addEventListener(type, self, true);
});
window.addEventListener("unload", function () {
["mousedown", "mousemove", "mouseup", "contextmenu", "DOMMouseScroll", "dragend"].forEach(function (type) {
gBrowser.mPanelContainer.removeEventListener(type, self, true);
});
}, false);
},
handleEvent: function (event) {
switch (event.type) {
case "mousedown":
if(/object|embed/i.test(event.target.localName)) return;
if (event.button == 2) {
this.sourceNode = event.target;
this.isMouseDownR = true;
this.hideFireContext = false;
[this.lastX, this.lastY, this.directionChain] = [event.screenX, event.screenY, ""];
}
if (event.button == 2 && this.isMouseDownL) {
this.isMouseDownR = false;
this.shouldFireContext = false;
this.hideFireContext = true;
this.directionChain = "L>R";
this.stopGesture(event);
} else if (event.button == 0) {
this.isMouseDownL = true;
if (this.isMouseDownR) {
this.isMouseDownL = false;
this.shouldFireContext = false;
this.hideFireContext = true;
this.directionChain = "L<R";
this.stopGesture(event);
}
}
break;
case "mousemove":
if (this.isMouseDownR) {
this.hideFireContext = true;
var [subX, subY] = [event.screenX - this.lastX, event.screenY - this.lastY];
var [distX, distY] = [(subX > 0 ? subX : (-subX)), (subY > 0 ? subY : (-subY))];
var direction;
if (distX < 10 && distY < 10) return;
if (distX > distY) direction = subX < 0 ? "L" : "R";
else direction = subY < 0 ? "U" : "D";
if (direction != this.directionChain.charAt(this.directionChain.length - 1)) {
this.directionChain += direction;
XULBrowserWindow.statusTextField.label = this.GESTURES[this.directionChain] ? "\u624b\u52bf: " + this.directionChain + " " + this.GESTURES[this.directionChain].name : "\u672a\u77e5\u624b\u52bf:" + this.directionChain;
}
this.lastX = event.screenX;
this.lastY = event.screenY;
}
break;
case "mouseup":
if (event.ctrlKey && event.button == 2) {
this.isMouseDownL = false;
this.isMouseDownR = false;
this.shouldFireContext = false;
this.hideFireContext = false;
this.directionChain = "";
event.preventDefault();
XULBrowserWindow.statusTextField.label = "\u53d6\u6d88\u624b\u52bf";
break;
}
if (this.isMouseDownR && event.button == 2) {
if (this.directionChain) this.shouldFireContext = false;
this.isMouseDownR = false;
this.directionChain && this.stopGesture(event);
} else if (event.button == 0 && this.isMouseDownL) {
this.isMouseDownL = false;
this.shouldFireContext = false;
}
break;
case "contextmenu":
if (this.isMouseDownL || this.isMouseDownR || this.hideFireContext) {
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
var contextmenu = pref.getBoolPref("dom.event.contextmenu.enabled");
pref.setBoolPref("dom.event.contextmenu.enabled", true);
setTimeout(function () {
pref.setBoolPref("dom.event.contextmenu.enabled", contextmenu);
}, 10);
event.preventDefault();
event.stopPropagation();
this.shouldFireContext = true;
this.hideFireContext = false;
}
break;
case "DOMMouseScroll":
if (this.isMouseDownR) {
event.preventDefault();
event.stopPropagation();
this.shouldFireContext = false;
this.hideFireContext = true;
this.directionChain = "W" + (event.detail > 0 ? "+" : "-");
this.stopGesture(event);
}
break;
case "dragend":
this.isMouseDownL = false;
}
},
stopGesture: function (event) {
(this.GESTURES[this.directionChain] ? this.GESTURES[this.directionChain].cmd(this, event) & (XULBrowserWindow.statusTextField.label = "") : (XULBrowserWindow.statusTextField.label = "\u672a\u77e5\u624b\u52bf:" + this.directionChain)) & (this.directionChain = "");
}
};
ucjsMouseGestures.init()
})()
游客

返回顶部