Motherless gallery keyboard navigation

Increases productivity when you're not being productive. Supports left and right handed browsing (arrow keys or A and D)

  1. // ==UserScript==
  2. // @name Motherless gallery keyboard navigation
  3. // @namespace niceme.me
  4. // @description Increases productivity when you're not being productive. Supports left and right handed browsing (arrow keys or A and D)
  5. // @include http://motherless.com/*
  6. // @version 1.1
  7. // @grant none
  8. // ==/UserScript==
  9. if ($('.previous-link').attr('href') != 'undefined') {
  10. prevUrl = 'http://motherless.com' + $('.previous-link').attr('href');
  11. nextUrl = 'http://motherless.com' + $('.next-link').attr('href');
  12. }
  13.  
  14. if (prevUrl != 'http://motherless.comundefined' || nextUrl != 'http://motherless.comundefined') {
  15. window.addEventListener('keydown', function (e) {
  16. if (((e.key == 'ArrowRight' || e.key == 'd') || // Firefox
  17. (e.keyCode == 39 || e.keyCode == 68)) && // Chrome
  18. nextUrl != 'http://motherless.comundefined') {
  19. document.location.href = nextUrl;
  20. } else if (((e.key == 'ArrowLeft' || e.key == 'a') || // Firefox
  21. (e.keyCode == 37 || e.keyCode == 65)) // Chrome
  22. && prevUrl != 'http://motherless.comundefined') {
  23. document.location.href = prevUrl;
  24. }
  25. });
  26. }