Keyboard navigation e621

Change the current page with arrow keys

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         Keyboard navigation e621
// @version      0.2
// @description  Change the current page with arrow keys
// @author       koreso
// @match        https://e621.net/posts/*
// @namespace https://greasyfork.org/users/510304
// ==/UserScript==

(function() {
    'use strict';

    // check if a next or previous button exists on the current page
    if(document.querySelector(".next")||document.querySelector(".prev"))window.onkeydown = page;

    function page(e) {
        // if the current focused element is a text box, abort
        if(document.activeElement.nodeName.match(/TEXTAREA|INPUT/))return;

        // 39 = right arrow key, 37 = left arrow key
        switch(e.keyCode){
            case 39:
                // change current url to the next button's url
                window.location.assign(document.querySelector(".next"));
                break;
            case 37:
                // idem but for the previous button
                window.location.assign(document.querySelector(".prev"));
                break;
        }
    }
})();