Greasy Fork is available in English.
And insta-scrolling for Mangakakalot & Manganelo
当前为
// ==UserScript==
// @name Next Chapter Shortcut
// @namespace http://greasyfork.icu/en/users/55535-sllypper
// @version 0.5
// @description And insta-scrolling for Mangakakalot & Manganelo
// @author sllypper
// @match https://mangakakalot.com/chapter/*
// @match https://manganelo.com/chapter/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let scrollAmount = 64;
let repeatBy = 32;
let scrollActions = {};
let buttons = document.getElementsByClassName('navi-change-chapter-btn');
if (buttons.length === 0) {
buttons = document.getElementsByClassName('btn-navigation-chap');
if (buttons.length === 0) return;
}
buttons = buttons[0].childNodes;
let prevButton = buttons[0];
let nextButton = buttons[buttons.length-1];
// if there's only one button
if (buttons.length != 2) {
// if it's the next button
// mangakakalot has "back" and "next" button classes switched around
if (buttons[0].classList.contains("back") || buttons[0].classList.contains("navi-change-chapter-btn-next")) {
// then we're in chapter 1
// and there's no prev button
prevButton = null;
} else {
// else we're in the last chapter
// and there's no next button
nextButton = null;
}
}
document.addEventListener("keydown", event => {
if (event.code === "KeyW" || event.code === "KeyK") {
if (scrollActions.up === undefined) {
scrollAction(-scrollAmount, repeatBy, 'up');
}
} else if (event.code === "KeyS" || event.code === "KeyJ") {
if (scrollActions.down === undefined) {
scrollAction(scrollAmount, repeatBy, 'down');
}
} else if (event.code === "KeyC" && nextButton != null) {
nextButton.click();
} else if (event.code === "KeyZ" && prevButton != null) {
prevButton.click();
}
});
document.addEventListener("keyup", event => {
if (event.code === "KeyW" || event.code === "KeyK") {
clearScrollAction('up');
} else if (event.code === "KeyS" || event.code === "KeyJ") {
clearScrollAction('down');
}
});
function scrollAction(amount, freq, id) {
scrollActions[id] = setInterval(() => {
window.scrollBy(0, amount);
}, freq)
}
function clearScrollAction(id) {
clearInterval(scrollActions[id]);
scrollActions[id] = undefined;
}
})();