Empornium GlobalArrowKeyNavigation

Companion script to NoShitEmpornium, adds arrow key navigation to all paginated content on the site

Versione datata 25/04/2022. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Empornium GlobalArrowKeyNavigation
// @namespace    http://www.empornium.me/
// @version      0.2
// @description  Companion script to NoShitEmpornium, adds arrow key navigation to all paginated content on the site
// @supportURL   https://github.com/ceodoe/noshitempornium/issues
// @homepageURL  https://github.com/ceodoe/noshitempornium/
// @author       ceodoe
// @include      /^https?://www\.empornium\.(me|sx|is)/*/
// @run-at       document-end
// ==/UserScript==
//
// Copyright © 2015-2021 ceodoe
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

document.onkeydown = function(event) {
    if(event.target.nodeName !== "TEXTAREA" && event.target.nodeName !== "INPUT") {
        if (event.code == "ArrowLeft") {
            let prevLink = document.getElementsByClassName("pager_prev")[0];
            if(prevLink) {
                event.preventDefault();
                prevLink.click();
            } else {
                let firstLink = document.getElementsByClassName("pager_first")[0];
                if(firstLink) {
                    event.preventDefault();
                    firstLink.click();
                }
            }
        } else if (event.code == "ArrowRight") {
            let nextLink = document.getElementsByClassName("pager_next")[0];
            if(nextLink) {
                event.preventDefault();
                nextLink.click();
            } else {
                let lastLink = document.getElementsByClassName("pager_last")[0];
                if(lastLink) {
                    event.preventDefault();
                    lastLink.click();
                }
            }
        }
    }
};