Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Листалка
- // @namespace AHOHNMYC_world
- // @version 0.0.0.0
- // @description Doesn't exists
- // @author Me
- // @match http://hpmor.ru/book/1/*
- // @grant none
- // ==/UserScript==
- addEventListener('keyup', e => {
- if (!e.ctrlKey)
- return;
- if (e.key == 'ArrowLeft')
- prevPage();
- if (e.key == 'ArrowRight')
- nextPage();
- });
- function nextPage() {
- gotoDelta(n => n+1)
- }
- function prevPage() {
- gotoDelta(n => n-1)
- }
- function gotoDelta(callback) {
- const chapterRegEx = /^(http?:\/\/hpmor\.ru\/book\/1\/)(\d+)(\/)$/;
- if (!chapterRegEx.test(location))
- return;
- let [, prefix, chapter, postfix] = location.toString().match(chapterRegEx);
- chapter = callback(+chapter)
- window.location = prefix + chapter + postfix;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement