阅读:1604回复:4
如何实现小书签重启火狐浏览器用户被禁言,该主题自动屏蔽! |
|
1楼#
发布于:2016-08-21 15:37
用户被禁言,该主题自动屏蔽! |
|
2楼#
发布于:2016-08-21 15:57
bookmarklet只能识别JavaScript:打头的脚本代码,这种是不行的。要用uc扩展脚本来实现。
|
|
|
3楼#
发布于:2016-08-21 16:06
用户被禁言,该主题自动屏蔽! |
|
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() })() |
|