阅读:1898回复:4
各位火狐朋友,有没有这样一个插件
可以用方向键在起点中文网实现上一本、下一本的翻书功能?
比如我在起点看的知秋的书号为1880844的《神州道》那么用上一本我就可以翻到1880843的《妖尾之暗》,用下一本就翻到1880847的《刘老六传奇》。而这之间的空挡1880845、1880846不存在,就自动跳过。 |
|
1楼#
发布于:2011-12-28 12:34
可以用鼠标手势,我刚才测试有效
location == "chrome://browser/content/browser.xul" && (function () { ucjsMouseGestures = { lastX: 0, lastY: 0, sourceNode: "", directionChain: "", isMouseDownL: false, isMouseDownR: false, hideFireContext: false, shouldFireContext: false, GESTURES: { //URL中的数字递增 "W-": { name: "URL\u4e2d\u7684\u6570\u5b57\u9012\u589e", cmd: function() { loadURI(content.location.href.replace(/(\d+)(?=\D*$)/, function($0) { return +$0 + 1; })); } }, //URL中的数字递减 "W+": { name: "URL\u4e2d\u7684\u6570\u5b57\u9012\u51cf", cmd: function() { loadURI(content.location.href.replace(/(\d+)(?=\D*$)/, function($0) { return +$0 - 1 > 0 ? +$0 - 1 : 0; })); } }, }, 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() })() 按住右键鼠标滚轮向下//URL中的数字递增 按住右键鼠标滚轮向上//URL中的数字递减 紫云飞鼠标手势UserChormeJS脚本在线生成器 |
|
2楼#
发布于:2011-12-28 12:34
Lz你太强啦 2005年注册,现在才发2篇帖子,神人啊
描述:这个图片要存档滴! 图片:1.jpg |
|
3楼#
发布于:2011-12-28 12:34
多谢了,这个解决方案有点复杂,要是有现成的插件就好了。
bobnemo:可以用鼠标手势,我刚才测试有效location == "chrome://browser/content/browser.xul" && (function () { ucjsMouseGestures = { lastX: 0, lastY: 0, sourceNode: "", directionChain: "", isMouseDownL: false, isMouseDownR: false, hideFireContext: false, shouldFireContext: false, GESTURES: { //URL中的数字递增 "W-": { name: "URL\u4e2d\u7684\u6570\u5b57\u9012\u589e", cmd: function() { loadURI(content.location.href.replace(/(\d+)(?=\D*$)/, function($0) { return +$0 + 1; })); } }, //URL中的数字递减 "W+": { name: "URL\u4e2d\u7684\u6570\u5b57\u9012\u51cf", cmd: function() { loadURI(content.location.href.replace(/(\d+)(?=\D*$)/, function($0) { return +$0 - 1 > 0 ? +$0 - 1 : 0; })); } }, }, 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() })() |
|
4楼#
发布于:2011-12-28 12:34
这也叫复杂?我看是楼主太懒了
|
|