Use ← and → to navigate to previous and next page in a forum
当前为
// ==UserScript==
// @name Next-Prev by Arrow keys
// @version 2.0
// @author theheroofvn
// @namespace https://greasyfork.org/scripts/6849-next-prev-by-arrow-key
// @include *thread*
// @include *forum*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
// @run-at document-start
// @grant none
// @description Use ← and → to navigate to previous and next page in a forum
// ==/UserScript==
$(document).ready(function() {
var detect_forum;
var prev, next, first, last;
var up, up_sub = '[itemtype="http://data-vocabulary.org/Breadcrumb"] > a';
if ($('script[src*="vbulletin"]').length > 0) {
detect_forum = 'v';
prev = 'a[rel="prev"]'; next = 'a[rel="next"]'; first = 'a[rel="start"]'; last = 'a[title^="Last"], a[title*="uối"]';
up = 'span.navbar a, li.navbit a';
} else if ($('script[src*="xenforo"]').length > 0) {
detect_forum = 'x';
prev = '.PageNav a.text:first-child'; next = last = '.PageNav a.text:last-child'; first = 'a[rel="start"]';
up = 'a.crumb';
} else return;
$(window).keydown(function(event) {
var key = event.keyCode || event.which;
if ($("textarea:focus, input:focus").length == 0) {
switch (key) {
case 37: $(prev)[0].click(); break;
case 39: $(next)[0].click(); break;
case 100: $(first)[0].click(); break;
case 102:
if (detect_forum == 'v') $(last)[0].click();
else if (detect_forum == 'x') $(last).prev()[0].click();
break;
case 104: ($(up).length > 0) ? $(up).last()[0].click() : $(up_sub).last()[0].click(); break;
default: break;
}
}
});
});