VG prev / next

Use ctrl-left / ctrl-right to move between forum pages, ctrl-shift-left / ctrl-shift-right to jump to the first and last page. On Mac, use Cmd-Ctrl and Shift-Cmd-Ctrl.

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         VG prev / next
// @namespace    http://vipergirls.to/
// @version      0.4
// @description  Use ctrl-left / ctrl-right to move between forum pages, ctrl-shift-left / ctrl-shift-right to jump to the first and last page. On Mac, use Cmd-Ctrl and Shift-Cmd-Ctrl.
// @author       tylenoesa
// @license      MIT
// @icon         https://www.google.com/s2/favicons?sz=64&domain=vipergirls.to
// @match        *://vipergirls.to/forums/*
// @match        *://vipergirls.to/forumdisplay.php*
// @match        *://vipergirls.to/search.php*
// @match        *://vipergirls.to/threads/*
// @match        *://planetviper.club/forums/*
// @match        *://planetviper.club/forumdisplay.php*
// @match        *://planetviper.club/search.php*
// @match        *://planetviper.club/threads/*
// @match        *://viper.to/forums/*
// @match        *://viper.to/forumdisplay.php*
// @match        *://viper.to/search.php*
// @match        *://viper.to/threads/*
// @match        *://viperbb.rocks/forums/*
// @match        *://viperbb.rocks/forumdisplay.php*
// @match        *://viperbb.rocks/search.php*
// @match        *://viperbb.rocks/threads/*
// @match        *://viperkats.eu/forums/*
// @match        *://viperkats.eu/forumdisplay.php*
// @match        *://viperkats.eu/search.php*
// @match        *://viperkats.eu/threads/*
// @match        *://viperohilia.art/forums/*
// @match        *://viperohilia.art/forumdisplay.php*
// @match        *://viperohilia.art/search.php*
// @match        *://viperohilia.art/threads/*
// @match        *://viperproxy.org/forums/*
// @match        *://viperproxy.org/forumdisplay.php*
// @match        *://viperproxy.org/search.php*
// @match        *://viperproxy.org/threads/*
// @match        *://vipervault.link/forums/*
// @match        *://vipervault.link/forumdisplay.php*
// @match        *://vipervault.link/search.php*
// @match        *://vipervault.link/threads/*
// @grant        none
// @run-at       document-body
// ==/UserScript==

(function() {
    'use strict';

    const isMac = window.navigator.platform.toLowerCase().startsWith('mac')
    const dispatch = {
        false: { // no shift
            'ArrowLeft': '.prev_next  a[rel="prev"]',
            'ArrowRight': '.prev_next  a[rel="next"]',
        },
        true: { // with shift
            'ArrowLeft': '.first_last a[rel="start"]',
            'ArrowRight': '.first_last a:not([rel])', // last page element has no 'rel' attribute :-/
        },
    }
    function debounce(func, timeout = 300){ // leading debounce, cancels repeated calls in the timeout window
       var timer = null
       return (...args) => {
           if (timer === null) func.apply(this, args)
           clearTimeout(timer)
           timer = setTimeout(() => {timer = null}, timeout)
       }
    }
    const handler = (e) => {
        if (e.ctrlKey && (!isMac || e.metaKey)) {
            var selector = dispatch[e.shiftKey][e.key]
            var elem = selector && document.querySelector(selector)
            elem && elem.click()
        }
    }
    window.addEventListener('keydown', debounce(handler))
})()