Skip to content

Instantly share code, notes, and snippets.

@Lewiscowles1986
Last active November 10, 2019 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lewiscowles1986/7716360299db979c2eeb2a404e5f381e to your computer and use it in GitHub Desktop.
Save Lewiscowles1986/7716360299db979c2eeb2a404e5f381e to your computer and use it in GitHub Desktop.
Prev Next JS injection
/*
* 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