Navigation Improvements for Surviving the World

Keyboard Navigation

  1. // ==UserScript==
  2. // @name Navigation Improvements for Surviving the World
  3. // @namespace http://userscripts.org/users/scuzzball
  4. // @description Keyboard Navigation
  5. // @include http://survivingtheworld.net/*
  6. // @version 1.0
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10.  
  11. navNext = document.getElementsByClassName('next')[0].childNodes[1].href;
  12. navPrev = document.getElementsByClassName('previous')[0].childNodes[1].href
  13.  
  14. function leftArrowPressed() {
  15. window.location = navPrev;
  16. }
  17.  
  18. function rightArrowPressed() {
  19. window.location = navNext;
  20. }
  21.  
  22. document.onkeydown = function(evt) {
  23. evt = evt || window.event;
  24. switch (evt.keyCode) {
  25. case 37:
  26. leftArrowPressed();
  27. break;
  28. case 39:
  29. rightArrowPressed();
  30. break;
  31. }
  32. };