// ==UserScript== // @name Copy Manga Simple Read // @namespace http://tampermonkey.net/ // @match https://www.copymanga.com/comic/*/chapter/* // @grant none // @version 1.3 // @author chemPolonium // @description manga reader for copy manga, J/K for UP/DOWN, LEFT/RIGHT for previous/next page. // @run-at document-end // @downloadURL none // ==/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) => { currentPageInd += x; currentPageInd = currentPageInd >= 0 ? currentPageInd : 0; currentPageInd = currentPageInd < comicList.children.length ? currentPageInd : comicList.children.length - 1; currentImage = comicList.children[currentPageInd].children[0]; }) // 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 (comicList.children[0].innerText == 'foo') { comicList.children[0].remove(); } else { comicList.insertAdjacentHTML('afterbegin','