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.

  1. // ==UserScript==
  2. // @name VG prev / next
  3. // @namespace http://vipergirls.to/
  4. // @version 0.4
  5. // @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.
  6. // @author tylenoesa
  7. // @license MIT
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=vipergirls.to
  9. // @match *://vipergirls.to/forums/*
  10. // @match *://vipergirls.to/forumdisplay.php*
  11. // @match *://vipergirls.to/search.php*
  12. // @match *://vipergirls.to/threads/*
  13. // @match *://planetviper.club/forums/*
  14. // @match *://planetviper.club/forumdisplay.php*
  15. // @match *://planetviper.club/search.php*
  16. // @match *://planetviper.club/threads/*
  17. // @match *://viper.to/forums/*
  18. // @match *://viper.to/forumdisplay.php*
  19. // @match *://viper.to/search.php*
  20. // @match *://viper.to/threads/*
  21. // @match *://viperbb.rocks/forums/*
  22. // @match *://viperbb.rocks/forumdisplay.php*
  23. // @match *://viperbb.rocks/search.php*
  24. // @match *://viperbb.rocks/threads/*
  25. // @match *://viperkats.eu/forums/*
  26. // @match *://viperkats.eu/forumdisplay.php*
  27. // @match *://viperkats.eu/search.php*
  28. // @match *://viperkats.eu/threads/*
  29. // @match *://viperohilia.art/forums/*
  30. // @match *://viperohilia.art/forumdisplay.php*
  31. // @match *://viperohilia.art/search.php*
  32. // @match *://viperohilia.art/threads/*
  33. // @match *://viperproxy.org/forums/*
  34. // @match *://viperproxy.org/forumdisplay.php*
  35. // @match *://viperproxy.org/search.php*
  36. // @match *://viperproxy.org/threads/*
  37. // @match *://vipervault.link/forums/*
  38. // @match *://vipervault.link/forumdisplay.php*
  39. // @match *://vipervault.link/search.php*
  40. // @match *://vipervault.link/threads/*
  41. // @grant none
  42. // @run-at document-body
  43. // ==/UserScript==
  44.  
  45. (function() {
  46. 'use strict';
  47.  
  48. const isMac = window.navigator.platform.toLowerCase().startsWith('mac')
  49. const dispatch = {
  50. false: { // no shift
  51. 'ArrowLeft': '.prev_next a[rel="prev"]',
  52. 'ArrowRight': '.prev_next a[rel="next"]',
  53. },
  54. true: { // with shift
  55. 'ArrowLeft': '.first_last a[rel="start"]',
  56. 'ArrowRight': '.first_last a:not([rel])', // last page element has no 'rel' attribute :-/
  57. },
  58. }
  59. function debounce(func, timeout = 300){ // leading debounce, cancels repeated calls in the timeout window
  60. var timer = null
  61. return (...args) => {
  62. if (timer === null) func.apply(this, args)
  63. clearTimeout(timer)
  64. timer = setTimeout(() => {timer = null}, timeout)
  65. }
  66. }
  67. const handler = (e) => {
  68. if (e.ctrlKey && (!isMac || e.metaKey)) {
  69. var selector = dispatch[e.shiftKey][e.key]
  70. var elem = selector && document.querySelector(selector)
  71. elem && elem.click()
  72. }
  73. }
  74. window.addEventListener('keydown', debounce(handler))
  75. })()