Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Userscript for Stand Still. Stay Silent
// ==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