Created
March 6, 2023 23:11
-
-
Save patagonaa/7020b41577685d52cb7685d61a323f63 to your computer and use it in GitHub Desktop.
z0r.de UserScript key shortcuts for navigation
This file contains hidden or 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 z0r key shortcuts | |
// @namespace http://www.example.com/gmscripts | |
// @description key shortcuts for z0r | |
// @include http://z0r.de/* | |
// @include https://z0r.de/* | |
// @version 0.3 | |
// ==/UserScript== | |
function addJQuery(callback) { | |
var script = document.createElement("script"); | |
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"); | |
script.addEventListener('load', function() { | |
var script = document.createElement("script"); | |
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();"; | |
document.body.appendChild(script); | |
}, false); | |
document.body.appendChild(script); | |
} | |
function main() { | |
var $ = jQ; | |
var prevLink; | |
var randLink; | |
var nextLink; | |
$("#unten").find("a").each(function(){ | |
var link = $(this); | |
link.click(function(){ | |
window.location = link.attr("href"); | |
}); | |
if(link.html() == "« Previous"){ | |
prevLink = link; | |
} | |
if(link.html() == "Random"){ | |
randLink = link; | |
} | |
if(link.html() == "Next »"){ | |
nextLink = link; | |
} | |
}); | |
$(document).keydown(function(e){ | |
if(e.which == 37){ // Left | |
prevLink.click(); | |
} | |
if(e.which == 38){ // Up | |
history.back(); | |
} | |
if(e.which == 39){ // Right | |
nextLink.click(); | |
} | |
if(e.which == 40){ // Down | |
randLink.click(); | |
} | |
}); | |
} | |
addJQuery(main); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment