Advertisement
Guest User

e621 swimmer v2

a guest
Aug 26th, 2016
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name             E621 Swimmer
  3. // @description      Navigate e621's pools with arrow keys
  4. // @include          http*://e621.net/post/show/*
  5. // @grant            none
  6. // ==/UserScript==
  7.  
  8. var tags = jQuery.find('a')
  9. //I do a.length/2 because I'm assuming it will be in
  10. //the first half of the page. I don't want to have to loop over
  11. //every link if it's not there
  12. for(var i = 0; i < tags.length/2; ++i) {
  13.     if(tags[i].innerText === '<< Previous') {
  14.         var prev = tags[i].href;
  15.     }
  16.     else if(tags[i].innerText === "Next >>") {
  17.         var next = tags[i].href;
  18.         break
  19.     }
  20. }
  21. document.addEventListener('keydown', function (e) {
  22.     if (e.keyCode === 37 && prev != null) {
  23.         window.location = prev;
  24.     }
  25.     else if (e.keyCode === 39 && next != null) {
  26.         window.location = next;
  27.     }
  28. }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement