您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds previous and next buttons/links to Extra Fabulous Comics to make it easier to read a lot of older comics.
当前为
// ==UserScript== // @name Extra Fabulous Comics simplifier and next and previous buttons // @namespace Tehhund // @match *://*.extrafabulouscomics.com/* // @grant none // @version 20 // @author Tehhund // @description Adds previous and next buttons/links to Extra Fabulous Comics to make it easier to read a lot of older comics. // @license MIT // @run-at document-start // ==/UserScript== const blankScreenUntilLoad = () => { style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = '* { filter: brightness(0); }'; style.id = 'tehhundScriptBlankStyle'; document.head.prepend(style); } blankScreenUntilLoad(); const unBlankScreen = () => { document.getElementById('tehhundScriptBlankStyle').remove(); } const calculateCurrentPrevNext = () => { let currentComic = window.location.href; currentComic = currentComic.slice(-5); // example: https://www.extrafabulouscomics.com/____1 currentComic = parseInt(currentComic.replace(/\D/g, '')); let nextComic = currentComic + 1; nextComic = nextComic.toString().padStart(5, '_'); nextComic = 'https://www.extrafabulouscomics.com/' + nextComic; let prevComic = currentComic - 1; prevComic = prevComic.toString().padStart(5, '_'); prevComic = 'https://www.extrafabulouscomics.com/' + prevComic; return { 'current': currentComic, 'next': nextComic, 'prev': prevComic }; } const addLinks = () => { let nextPrevLinks = document.getElementsByClassName('tehhundScript'); while (nextPrevLinks.length > 0) { nextPrevLinks[0].remove(); // For of was skipping elements so this fixes that. } let comic = document.querySelectorAll('img')[0].cloneNode(); document.body.innerHTML += '<style>* { background: black; }</style>'; const allElems = document.body.getElementsByTagName('*'); for (let elem of allElems) { //elem.style.filter = 'brightness(0%)'; elem.remove(); } document.body.style.backgroundColor = "black"; document.body.appendChild(comic); comic.style.paddingTop = '7rem'; comic.style.paddingBottom = '7rem'; const currentComic = window.location.href; document.body.innerHTML += '<a class="tehhundScript tehhundScriptPrev" href="https://paulkoepke.com/redirector/?redirectUrl=' + currentComic + '&direction=prev" style="position: fixed;bottom: 5rem;left: 0;border: 1px solid #000000;font-size: 1rem;">Prev</button>'; document.body.innerHTML += '<a class="tehhundScript tehhundScriptPrev" href="https://paulkoepke.com/redirector/?redirectUrl=' + currentComic + '&direction=prev" style="position: fixed;top: 5rem;left: 0;border: 1px solid #000000;font-size: 1rem;">Prev</button>'; document.body.innerHTML += '<a class="tehhundScript tehhundScriptNext" href="https://paulkoepke.com/redirector/?redirectUrl=' + currentComic + '&direction=next" style="position: fixed;bottom: 5rem;right: 0;border: 1px solid #000000;font-size: 1rem;">Next</button>'; document.body.innerHTML += '<a class="tehhundScript tehhundScriptNext" href="https://paulkoepke.com/redirector/?redirectUrl=' + currentComic + '&direction=next" style="position: fixed;top: 5rem;right: 0;border: 1px solid #000000;font-size: 1rem;">Next</button>'; // EFC website is slow to load new pages. This should speed it up a bit. const linkRels = ['prefetch', 'preload', 'preconnect', 'dns-prefetch', 'prerender']; for (let rel of linkRels) { document.body.innerHTML += '<link link rel="' + rel + '" href="' + calculateCurrentPrevNext()['next'] + '" >'; document.body.innerHTML += '<link link rel="' + rel + '" href="' + calculateCurrentPrevNext()['prev'] + '" >'; } //Move the whole body up a bit. /*document.getElementsByTagName('body')[0].style.position = 'relative'; document.getElementsByTagName('body')[0].style.top = '-2rem';*/ } window.addEventListener("load", (event) => { addLinks(); unBlankScreen(); });