Thread Navigating by Arrow keys

Use ← or → and Ctrl to navigate to previous, next, first and last page

Stan na 12-12-2014. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Thread Navigating by Arrow keys
// @version     2.3
// @author      theheroofvn
// @namespace   https://greasyfork.org/scripts/6849-next-prev-by-arrow-key
// @include     /^.*(thread|forum).*$/
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
// @run-at      document-start
// @grant       none
// @description Use ← or → and Ctrl to navigate to previous, next, first and last page
// ==/UserScript==

$(document).ready(function() {
    var detect_forum,
    prev, next, first, last,
    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;
    var multi = {17 : false, 8 : false, 37 : false, 39 : false},
    multi1 = {17 : false, 8 : false}, multi2 = {17 : false, 37 : false}, multi3 = {17 : false, 39: false};
    $(window).keydown(function(event) {
        var key = event.keyCode;
        if ($("textarea:focus, input:focus").length == 0) {
            if (key in multi) multi[key] = true;
            if (key in multi1) {
                if (multi[17] && multi[8]) ($(up).length > 0) ? $(up).last()[0].click() : $(up_sub).last()[0].click();
            } else if (key in multi2) {
                if (!multi[17] && multi[37]) $(prev)[0].click();
                else if (multi[17] && multi[37]) $(first)[0].click();
            } else if (key in multi3) {
                if (!multi[17] && multi[39]) $(next)[0].click();
                else if (multi[17] && multi[39]) {
                    if (detect_forum == 'v') $(last)[0].click();
                    else if (detect_forum == 'x') $(last).prev()[0].click();
                }
            }
        }
    }).keyup(function(event) {
        if (event.keyCode in multi) multi[key] = false;
    });;
});