Last active
November 10, 2019 10:03
-
-
Save Lewiscowles1986/7716360299db979c2eeb2a404e5f381e to your computer and use it in GitHub Desktop.
Prev Next JS injection
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
/* | |
* Used via https://chrome.google.com/webstore/detail/user-javascript-and-css/nbhcbdghjpllgmfilhnhkllmkecfmpld | |
* to embed JS in all web-pages that are compliant to enable keyboard-navigation of blog posts | |
*/ | |
(function() { | |
window.addEventListener('keydown', function(e) { | |
switch(e.key) { | |
case 'Left': // IE11 BS | |
case 'ArrowLeft': | |
var link = document.querySelector('a[rel="prev"], .prev, #previtem'); | |
if(link) { link.click(); } | |
break; | |
case 'Right': // IE11 BS | |
case 'ArrowRight': | |
var link = document.querySelector('a[rel="next"], .next, #nextitem'); | |
if(link) { link.click(); } | |
break; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment