Keyboard Navigation for Worm

Just adds arrow key movement.

  1. // ==UserScript==
  2. // @name Keyboard Navigation for Worm
  3. // @description Just adds arrow key movement.
  4. // @namespace http://userscripts.org/users/scuzzball
  5. // @include http://parahumans.wordpress.com/*
  6. // @grant none
  7. // @version 1.0
  8. // ==/UserScript==
  9.  
  10. if(document.getElementsByClassName('nav-next')[0].hasChildNodes()){//so if the menunav-next div is not empty, get the next link. Otherwise, blank.
  11. navNext = document.getElementsByClassName('nav-next')[0].firstChild.getAttribute("href");
  12. }else{
  13. navNext="";
  14. }
  15.  
  16. if(document.getElementsByClassName('nav-previous')[0].hasChildNodes()){//so if the menunav-next div is not empty, get the next link. Otherwise, blank.
  17. navPrev = document.getElementsByClassName('nav-previous')[0].firstChild.getAttribute("href");
  18. }else{
  19. navPrev="";
  20. }
  21.  
  22. function leftArrowPressed() {
  23. window.location = navPrev;
  24. }
  25.  
  26. function rightArrowPressed() {
  27. window.location = navNext;
  28. }
  29.  
  30. document.onkeydown = function(evt) {
  31. evt = evt || window.event;
  32. switch (evt.keyCode) {
  33. case 37:
  34. leftArrowPressed();
  35. break;
  36. case 39:
  37. rightArrowPressed();
  38. break;
  39. }
  40. };