Last active
October 30, 2019 09:07
-
-
Save JulianWebb/62d6f81d74d9fb0b2f3cbd7b84b2f6a3 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Check, Please! Arrow Keys | |
// @namespace https://gist.github.com/JulianWebb | |
// @version 0.2 | |
// @author Pongles | |
// @description Adds the ability to navigate the comic using just the left and right arrow keys | |
// @icon https://checkpleasecomic.com/favicon.ico | |
// @match https://checkpleasecomic.com/comic/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
console.log('Check, Please! Arrow Keys is working!') | |
document.onkeydown = function(e) { | |
switch (e.key) { | |
case 'ArrowLeft': | |
let prevInChapter = document.querySelector(".slick-prev"); | |
if (prevInChapter.className.includes("slick-disabled")) { | |
let prevChapter = document.querySelector(".cc-prev"); | |
prevChapter.click() | |
} else { | |
prevInChapter.click() | |
} | |
break; | |
case 'ArrowRight': | |
let nextInChapter = document.querySelector(".slick-next"); | |
if (nextInChapter.className.includes("slick-disabled")) { | |
let nextChapter = document.querySelector(".cc-next"); | |
nextChapter.click(); | |
} else { | |
nextInChapter.click(); | |
} | |
break; | |
default: return; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment