Advertisement
Guest User

lowbird.com Arrow Keys (Chrome user script)

a guest
Feb 10th, 2013
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @match http://www.lowbird.com/*
  3. // ==/UserScript==
  4.  
  5. /*global window */
  6. (function () {
  7.     "use strict";
  8.     var
  9.         w = window,
  10.         d = window.document,
  11.  
  12.         prevBar = d.getElementById('prevBar'),
  13.         nextBar = d.getElementById('nextBar'),
  14.         prevUrl = prevBar ? prevBar.getAttribute('href') : null,
  15.         nextUrl = nextBar ? nextBar.getAttribute('href') : null,
  16.  
  17.         keyDownHandler = function (e) {
  18.             if (e.target.nodeName !== 'BODY') {
  19.                 return true;
  20.             }
  21.             if (e.keyCode === 37 && prevUrl) {
  22.                 d.location.href = prevUrl;
  23.             } else if (e.keyCode === 39 && nextUrl) {
  24.                 d.location.href = nextUrl;
  25.             }
  26.             return true;
  27.         };
  28.  
  29.     w.onkeydown = keyDownHandler;
  30. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement