Навигация на bash.im

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

2016-03-30 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Навигация на bash.im
// @description Стрелки вперёд-назад у номера цитаты
// @include     http://bash.im/quote/*
// @icon        http://bash.im/favicon.ico
// @grant       none
// @version 0.0.1.20160330050710
// @namespace https://greasyfork.org/users/7568
// ==/UserScript==

var link = document.getElementsByClassName('id')[0]; // ссылка на текущий номер
    number = link.href.match(/[^\/]+$/), // выдрать из неё номер
    numberback = parseInt(number) - 1, // предыдущий
    numbernext = numberback + 2, // следующий
    linkback = document.createElement('a'), // заготовка новых ссылок
    linknext = document.createElement('a'),
    textback = document.createTextNode('[<<]'), // и текстов
    textnext = document.createTextNode('[>>]');
linkback.href = '/quote/'+numberback; // одевание на новые ссылки путей с номерами
linknext.href = '/quote/'+numbernext;
linkback.className = linknext.className = 'id'; // присвоение класса
linkback.style = link.style = linknext.style = 'margin: -3px; position: relative;'; // группирование всех трёх элементов
linkback.appendChild(textback); // вставка текстов
linknext.appendChild(textnext);
link.parentNode.insertBefore(linkback,link); // вставка новых ссылок
link.parentNode.appendChild(linknext);