Bash Navigator

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

  1. // ==UserScript==
  2. // @name Bash Navigator
  3. // @version 2019.08.23
  4. // @description Стрелки вперёд-назад у номера цитаты
  5. // @include http*://bash.im/quote/*
  6. // @author Rainbow-Spike
  7. // @namespace https://greasyfork.org/users/7568
  8. // @homepage https://greasyfork.org/ru/users/7568-dr-yukon
  9. // @icon https://www.google.com/s2/favicons?domain=bash.im
  10. // @grant none
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. var parent = document.querySelector ( '.quote__header' ),
  15. link = parent.querySelector ( '.quote__header_permalink' ), // ссылка на текущий номер
  16. num = link.href.match ( /[^\/]+$/ ), // выдрать из неё номер
  17. num_back = parseInt ( num ) - 1, // предыдущий
  18. num_next = num_back + 2, // следующий
  19. back = document.createElement ( 'a' ), // заготовка новых ссылок
  20. next = document.createElement ( 'a' ),
  21. t_back = document.createTextNode ( '[<<]' ), // и текстов
  22. t_next = document.createTextNode ( '[>>]' );
  23.  
  24. back.href = '/quote/' + num_back; // одевание на новые ссылки путей с номерами
  25. back.appendChild ( t_back ); // вставка текстов
  26. back.accessKey = 'p';
  27. parent.insertBefore ( back, link ); // вставка новых ссылок
  28.  
  29. next.href = '/quote/' + num_next;
  30. next.appendChild ( t_next );
  31. next.accessKey = 'n';
  32. parent.appendChild ( next );
  33.  
  34. back.className = next.className = 'quote__header_permalink'; // общий стиль
  35. parent.style = 'font-size: 20px; position: relative; bottom: 7px;';