Schlock Mercenary Navigation Improvements

Makes the image a link to the next comic, and arrow keys control movement.

  1. // ==UserScript==
  2. // @name Schlock Mercenary Navigation Improvements
  3. // @namespace http://userscripts.org/users/Scuzzball
  4. // @description Makes the image a link to the next comic, and arrow keys control movement.
  5. // @include http://www.schlockmercenary.com/*
  6. // @version 1.0
  7. // ==/UserScript==
  8.  
  9.  
  10.  
  11.  
  12. if(document.getElementById('nav-next').tagName == "A") //If the next link is a link(It's a div when no new comic)
  13. {
  14. var navNext = document.getElementById('nav-next');
  15. }
  16. else
  17. {
  18. var navNext = ""
  19. }
  20.  
  21. document.getElementById('comic').innerHTML = '<a href="' + navNext + '">' + document.getElementById('comic').innerHTML + '</a>';
  22.  
  23.  
  24. function leftArrowPressed() {
  25. window.location = document.getElementById('nav-previous');
  26. }
  27.  
  28. function rightArrowPressed() {
  29. window.location = navNext;
  30. }
  31.  
  32. document.onkeydown = function(evt) {
  33. evt = evt || window.event;
  34. switch (evt.keyCode) {
  35. case 37:
  36. leftArrowPressed();
  37. break;
  38. case 39:
  39. rightArrowPressed();
  40. break;
  41. }
  42. };