Bash Navigator

Стрелки вперёд-назад у номера цитаты

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			Bash Navigator
// @version			2019.08.23
// @description		Стрелки вперёд-назад у номера цитаты
// @include			http*://bash.im/quote/*
// @author			Rainbow-Spike
// @namespace		https://greasyfork.org/users/7568
// @homepage		https://greasyfork.org/ru/users/7568-dr-yukon
// @icon			https://www.google.com/s2/favicons?domain=bash.im
// @grant			none
// @run-at			document-end
// ==/UserScript==

var parent = document.querySelector ( '.quote__header' ),
	link = parent.querySelector ( '.quote__header_permalink' ), // ссылка на текущий номер
    num = link.href.match ( /[^\/]+$/ ), // выдрать из неё номер
    num_back = parseInt ( num ) - 1, // предыдущий
    num_next = num_back + 2, // следующий
    back = document.createElement ( 'a' ), // заготовка новых ссылок
    next = document.createElement ( 'a' ),
    t_back = document.createTextNode ( '[<<]' ), // и текстов
    t_next = document.createTextNode ( '[>>]' );

back.href = '/quote/' + num_back; // одевание на новые ссылки путей с номерами
back.appendChild ( t_back ); // вставка текстов
back.accessKey = 'p';
parent.insertBefore ( back, link ); // вставка новых ссылок

next.href = '/quote/' + num_next;
next.appendChild ( t_next );
next.accessKey = 'n';
parent.appendChild ( next );

back.className = next.className = 'quote__header_permalink'; // общий стиль
parent.style = 'font-size: 20px; position: relative; bottom: 7px;';