From e0ceb3222f40ba9ca4b67a235f1d9382288d094c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 24 Jun 2011 20:45:05 +0200 Subject: [PATCH] Replace 4chan's previous/next page. --- 4chan_x.user.js | 16 ++++++++++++++-- script.coffee | 8 ++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 33c744992..4f4d4a612 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -707,6 +707,8 @@ keybinds.previousReply = (key = $.getValue('key/previousReply', 0)).length ? key : 'K'; keybinds.nextThread = (key = $.getValue('key/nextThread', 0)).length ? key : 'n'; keybinds.previousThread = (key = $.getValue('key/previousThread', 0)).length ? key : 'p'; + keybinds.nextPage = (key = $.getValue('key/nextPage', 0)).length ? key : 'alt+x'; + keybinds.previousPage = (key = $.getValue('key/previousPage', 0)).length ? key : 'alt+z'; keybinds.openThreadTab = (key = $.getValue('key/openThreadTab', 0)).length ? key : 'o'; keybinds.openThread = (key = $.getValue('key/openThread', 0)).length ? key : 'O'; keybinds.expandThread = (key = $.getValue('key/expandThread', 0)).length ? key : 'e'; @@ -720,7 +722,7 @@ }, cb: { keydown: function(e) { - var kc, key, o, qr, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value; + var kc, key, o, qr, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2; kc = e.keyCode; if ((65 <= kc && kc <= 90)) { key = String.fromCharCode(kc); @@ -808,6 +810,16 @@ case keybinds.hide: threadHiding.toggle(thread); break; + case keybinds.nextPage: + if ((_ref = $('input[value=Next]')) != null) { + _ref.click(); + } + break; + case keybinds.previousPage: + if ((_ref2 = $('input[value=Previous]')) != null) { + _ref2.click(); + } + break; default: return; } @@ -1000,7 +1012,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, html, input, key, li, link, main, obj, overlay, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "

"; + html = "

"; dialog = $.el('div', { id: 'options', innerHTML: html diff --git a/script.coffee b/script.coffee index 38809651d..75949678b 100644 --- a/script.coffee +++ b/script.coffee @@ -501,6 +501,8 @@ keybinds = keybinds.previousReply = if (key = $.getValue 'key/previousReply', 0).length then key else 'K' keybinds.nextThread = if (key = $.getValue 'key/nextThread', 0).length then key else 'n' keybinds.previousThread = if (key = $.getValue 'key/previousThread', 0).length then key else 'p' + keybinds.nextPage = if (key = $.getValue 'key/nextPage', 0).length then key else 'alt+x' + keybinds.previousPage = if (key = $.getValue 'key/previousPage', 0).length then key else 'alt+z' keybinds.openThreadTab = if (key = $.getValue 'key/openThreadTab', 0).length then key else 'o' keybinds.openThread = if (key = $.getValue 'key/openThread', 0).length then key else 'O' keybinds.expandThread = if (key = $.getValue 'key/expandThread', 0).length then key else 'e' @@ -580,6 +582,10 @@ keybinds = watcher.toggle thread when keybinds.hide threadHiding.toggle thread + when keybinds.nextPage + $('input[value=Next]')?.click() + when keybinds.previousPage + $('input[value=Previous]')?.click() else return e.preventDefault() @@ -791,6 +797,8 @@ options = Select previous reply See next thread See previous thread + Jump next page + Jump previous page Open thread in current tab Open thread in new tab Expand thread