Skip to content

Instantly share code, notes, and snippets.

@JulianWebb
Last active October 30, 2019 09:07
Show Gist options
  • Save JulianWebb/62d6f81d74d9fb0b2f3cbd7b84b2f6a3 to your computer and use it in GitHub Desktop.
Save JulianWebb/62d6f81d74d9fb0b2f3cbd7b84b2f6a3 to your computer and use it in GitHub Desktop.
// ==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