Skip to content

Instantly share code, notes, and snippets.

@RayBB
Created April 7, 2020 20:33
Show Gist options
  • Save RayBB/9c74e1e4678e38c51ec532c0fa0f5e81 to your computer and use it in GitHub Desktop.
Save RayBB/9c74e1e4678e38c51ec532c0fa0f5e81 to your computer and use it in GitHub Desktop.
Read Calvin and Hobbes without the fuss
/*
I wanted to read calvin and hobbes with the least fuss possible.
That includes:
1. Only see the comic
2. Have keyboard navigation
https://www.gocomics.com/calvinandhobbes/1985/11/18 is the first comic
I like installed the ublock origin extension and added these custom filters
! 4/5/2020 https://www.gocomics.com
www.gocomics.com##.gc-gap-none.gc-content__1col
www.gocomics.com##.hidden-md-down.js-gc-lock-parent.border-right.bg-white.layout-2col-sidebar
www.gocomics.com##.ad-leaderboard_feature_item-container.amu-container-ad
www.gocomics.com##.content-section-padded-sm
www.gocomics.com##.mt-5
www.gocomics.com##div.row:nth-of-type(3) > .col-12
www.gocomics.com##.gc-deck
www.gocomics.com##.gc-rec-slider
www.gocomics.com##.gc-page__full
www.gocomics.com##.comic__interactions-container
www.gocomics.com##.comic__buy-button
www.gocomics.com##.content-section-sm.text-center.gc-section-title-more
Add keyboard navigation by installing the extension greasemonkey (or tampermonkey for Chrome).
Then add the following userscript.
*/
// ==UserScript==
// @name Calvin and Hobbes
// @namespace http://gocomics.com/
// @version 0.1
// @description Keyboard navigation for calvin and hobbes
// @author RayBB
// @match https://www.gocomics.com/calvinandhobbes/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.querySelector('.gc-page-container').style.marginTop = 0;
$(document).on("keydown", function (event) {
if (event.keyCode == 37) {
console.log('left arrow pressed');
document.querySelector('a.fa.btn.btn-outline-secondary.btn-circle.fa-caret-left.sm.js-previous-comic').click();
}
if (event.keyCode == 38) {
console.log('up arrow pressed');
}
if (event.keyCode == 39) {
console.log('right arrow pressed');
document.querySelector("a.fa.btn.btn-outline-secondary.btn-circle.fa-caret-right.sm").click();
}
if (event.keyCode == 40) {
console.log('down arrow pressed');
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment