Advertisement
Chronos_Ouroboros

e621 thingy

Nov 10th, 2015
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. // ==UserScript==
  2. // @name e621 Post Stuff
  3. // @version 0.1
  4. // @description Shtuff
  5. // @author Chronos Ouroboros
  6. // @match https://e621.net/post/show/*
  7. // @match http://e621.net/post/show/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. //176827
  12. //Previous: <a href="/post/show/">&lt;&lt;</a>
  13. //Next: <a href="/post/show/">&gt;&gt;</a>
  14.  
  15. var links = document.getElementsByTagName ("a");
  16. var previousLink = "";
  17. var nextLink = "";
  18.  
  19. for (var i = 0; i < links.length; i++) {
  20. if (links [i].innerHTML == "&lt;&lt;") {
  21. previousLink = links[i].href;
  22. break;
  23. }
  24. }
  25. for (var i = 0; i < links.length; i++) {
  26. if (links [i].innerHTML == "&gt;&gt;") {
  27. nextLink = links[i].href;
  28. break;
  29. }
  30. }
  31.  
  32. document.onkeypress = function (e) {
  33. e = e || window.event;
  34.  
  35. if (document.activeElement.tagName.toUpperCase() != "TEXTAREA" &&
  36. document.activeElement.tagName.toUpperCase() != "INPUT") {
  37. if ((e.keyCode == 101 || e.keyCode == 69) &&
  38. (nextLink != ""))
  39. document.location.href = nextLink;
  40. else if ((e.keyCode == 113 || e.keyCode == 81)
  41. && (previousLink != ""))
  42. document.location.href = previousLink;
  43.  
  44. if (e.keyCode == 119 ||
  45. e.keyCode == 87)
  46. window.scrollBy(0, -40);
  47. else if (e.keyCode == 115 || e.keyCode == 83)
  48. window.scrollBy(0, 40);
  49.  
  50. if (e.keyCode == 97 || e.keyCode == 65)
  51. window.scrollBy(-40, 0);
  52. else if (e.keyCode == 100 || e.keyCode == 68)
  53. window.scrollBy(40, 0);
  54. }
  55. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement