Last active
August 29, 2015 14:17
-
-
Save orng/c44890bf962056cb6fc5 to your computer and use it in GitHub Desktop.
Crude UserScript hack that enables arrow navigation for the html version of "Artificial Intelligence - Foundations of Computational Agents"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name ArtInt Navigator | |
// @namespace gorn/aiNav | |
// @description Enables back and forth navigation using the arrow keys on AI book webpage | |
// @include http://artint.info/html/ArtInt_*.html | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
var base = "http://artint.info/html/ArtInt_"; | |
var end = ".html" | |
function getNumber() | |
{ | |
var url = document.URL; | |
var number = parseInt(url.match("[0-9]+")); | |
return number; | |
} | |
document.onkeydown = function(evt) { | |
evt = evt || window.event; | |
switch (evt.keyCode) { | |
case 37: | |
newUrl = base + (getNumber() - 1) + end; | |
document.location.href = newUrl; | |
break; | |
case 39: | |
newUrl = base + (getNumber() + 1) + end; | |
document.location.href = newUrl; | |
break; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment