Next-Prev By Arrow Key

Cái tên nói lên tất cả rồi

Tính đến 11-12-2014. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Next-Prev By Arrow Key
// @version     1.0
// @author      theheroofvn
// @namespace   https://greasyfork.org/scripts/6849-next-prev-by-arrow-key
// @include     *showthread.php*
// @include     */threads/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
// @run-at      document-start
// @grant       none
// @description Cái tên nói lên tất cả rồi
// ==/UserScript==

$(document).ready(function() {
    var detect_forum;
    var prev, next, first, last;
    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 Page"], a[title^="Trang cuối"]';
    } 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"]';
    } else return;
    $(window).keydown(function(event) {
        var key = event.keyCode || event.which;
        if ($("textarea:focus").length == 0) {
            switch (key) {
                case 37: $(prev)[0].click(); break;
                case 39: $(next)[0].click(); break;
                case 97: $(first)[0].click(); break;
                case 99: 
                    if (detect_forum == 'v') $(last)[0].click();
                    else if (detect_forum == 'x') $(last).prev()[0].click();
                    break;
                default: break;
            }
        }
    });
});