Next-Prev By Arrow Key

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

目前為 2014-12-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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;
            }
        }
    });
});