Last active
August 29, 2015 14:08
-
-
Save Belphemur/2920677efbfde686d0e1 to your computer and use it in GitHub Desktop.
Userscript for Stand Still. Stay Silent
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 Stand Still. Stay silent Arrow Keys | |
// @namespace http://aaflalo.me | |
// @version 0.1 | |
// @description Using the arrows key to navigate throught the comic | |
// @author Antoine Aflalo | |
// @match http://www.sssscomic.com/comic.php?page=* | |
// @include http://www.sssscomic.com/comic.php?page=* | |
// @updateURL https://gist.github.com/Belphemur/2920677efbfde686d0e1/raw/Stand%20Still.%20Stay%20Silent.user.js | |
// @downloadURL https://gist.github.com/Belphemur/2920677efbfde686d0e1/raw/Stand%20Still.%20Stay%20Silent.user.js | |
// @grant none | |
// ==/UserScript== | |
var basicURL = "http://www.sssscomic.com/comic.php?page="; | |
function getComicPage () { | |
var re = /page=(\d+)/; | |
id = re.exec(document.location); | |
return parseInt(id[1]); | |
} | |
function changePage(id) { | |
if(id < 0) | |
return; | |
document.location.href = basicURL + id; | |
} | |
function checkKey(e) { | |
e = e || window.event; | |
if (e.keyCode == '37') { | |
changePage(getComicPage() - 1); | |
} | |
else if (e.keyCode == '39') { | |
changePage(getComicPage() +1); | |
} | |
} | |
document.onkeydown = checkKey; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment