Skip to content

Instantly share code, notes, and snippets.

@lettas
Created December 13, 2021 08:37
Show Gist options
  • Save lettas/a211525ec261b9e673f56901a61de74a to your computer and use it in GitHub Desktop.
Save lettas/a211525ec261b9e673f56901a61de74a to your computer and use it in GitHub Desktop.
ジャンプ+で週刊少年ジャンプを読んでるときに便利なショートカットキーを提供する([↓]次の連載 [↑]前の連載 [N]次の号 [P]前の号)
// ==UserScript==
// @name Weekly Shonen Jump Keyboard Shortcuts for Jump plus
// @namespace https://shonenjumpplus.com/
// @version 0.1
// @description ジャンプ+で週刊少年ジャンプを読んでるときに便利なショートカットキーを提供する([↓]次の連載 [↑]前の連載 [N]次の号 [P]前の号)
// @author me
// @match https://shonenjumpplus.com/magazine/*
// @grant none
// @run-at document-idle
// @require https://code.jquery.com/jquery-3.6.0.slim.min.js
// ==/UserScript==
/* globals jQuery, $, waitForKeyElements */
(function() {
'use strict';
const clickATag = (selector) => {
const href = $(selector).attr('href');
if (href !== undefined) {
location.href = href;
}
};
$(document).keydown((e) => {
switch(e.keyCode) {
case 38: // up
clickATag('a.goto-prev-content');
e.preventDefault();
break;
case 40: // down
clickATag('a.goto-next-content');
e.preventDefault();
break;
case 78: // n
clickATag('a.next-link');
e.preventDefault();
break;
case 80: // p
clickATag('a.previous-link');
e.preventDefault();
break;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment