manga reader for copy manga, J/K for UP/DOWN, LEFT/RIGHT for previous/next page.
当前为
// ==UserScript==
// @name Copy Manga Simple Read
// @namespace http://tampermonkey.net/
// @match https://www.copymanga.com/comic/*/chapter/*
// @grant none
// @version 1.4
// @author chemPolonium
// @description manga reader for copy manga, J/K for UP/DOWN, LEFT/RIGHT for previous/next page.
// @run-at document-end
// ==/UserScript==
(function() {
'use strict'
console.log('test');
let clientHeight = document.body.clientHeight;
document.getElementsByClassName('header')[0].remove();
let comicList = document.getElementsByClassName('comicContent-list')[0];
// let headerWhiteSpace = comicList.children[0].children[0].offsetTop;
let currentPageInd = -1;
let currentImage;
let movePage = ((x) => {
console.log('currentPageInd: ' + currentPageInd)
currentPageInd += x;
currentPageInd = currentPageInd >= 0 ? currentPageInd : 1;
currentPageInd = currentPageInd < comicList.children.length ? currentPageInd : comicList.children.length - 1;
currentImage = comicList.children[currentPageInd].children[0];
console.log('currentPageInd after add: ' + currentPageInd)
})
// window.scrollTo(0, headerWhiteSpace);
let evt = new UIEvent('scroll');
let onePageDown = (() => {
// simulate the scroll for preload
// the script is like this: total client height / 3 < window scrollY then not load
// so first scroll Y to 0
window.scrollTo(0, 0);
for (let i = 0; i < 2; i++) {
window.dispatchEvent(evt);
// dispatch the scroll event for preload
movePage(1);
// the set will not work if important is not added
currentImage.setAttribute('style', 'height: 100vh !important; width: unset !important;');
}
window.scrollTo(0, currentImage.offsetTop);
})
let onePageUp = (() => {
movePage(-2);
window.scrollTo(0, currentImage.offsetTop);
})
let switchParity = (() => {
if (currentPageInd < 0) {
onePageDown();
}
if (comicList.children[0].innerText == 'foo') {
comicList.children[0].remove();
} else {
comicList.insertAdjacentHTML('afterbegin','<li>foo</li>');
}
})
let footer = document.getElementsByClassName('footer')[0];
let footerChildren = footer.children;
let prevChapterHref = footerChildren[1].children[0].href;
let nextChapterHref = footerChildren[3].children[0].href;
let chapterListHref = footerChildren[4].children[0].href;
document.addEventListener('keydown', (event) => {
switch (event.code) {
case 'ArrowRight':
window.location = nextChapterHref;
break;
case 'ArrowLeft':
window.location = prevChapterHref;
break;
case 'KeyK':
onePageUp();
break;
case 'KeyJ':
onePageDown();
break;
case 'KeyL':
window.location = chapterListHref;
break;
case 'Semicolon':
switchParity();
default:
console.log('key: ' + event.key + ' code: ' + event.code);
}
});
footer.remove();
comicList.setAttribute('style', 'display:grid;grid-template-columns: repeat(2, 1fr);direction: rtl;')
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址