// ==UserScript== // @name RL Arrow Key Next/Prev Chapter // @namespace ultrabenosaurus.ReLibrary // @version 0.4 // @description Enable next / previous chapter on right / left arrow keys on Re:Library. // @author Ultrabenosaurus // @source https://greasyfork.org/en/users/437117-ultrabenosaurus?sort=name // @match https://re-library.com/translations/* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; document.onkeyup = function(e){ e = e || window.event; //console.log(e.keyCode); if (e.keyCode == '37') { // left arrow e.preventDefault(); var pLink = document.querySelectorAll('div.entry-content>p+hr+div[style="float: left;"]>a'); if( pLink.length == 0 ) { pLink = document.querySelectorAll('div.entry-content a.prevPageLink'); } pLink[0].click(); pLink = null; } else if (e.keyCode == '39') { // right arrow e.preventDefault(); var nLink = document.querySelectorAll('div.entry-content>p+hr+div+div[style="float: right;"]>a'); if( nLink.length == 0 ) { nLink = document.querySelectorAll('div.entry-content a.nextPageLink'); } nLink[0].click(); nLink = null; } }; })();