// ==UserScript== // @name manhuagui // @namespace https://github.com/IronKinoko/userscripts/tree/master/packages/manhuagui // @version 1.0.7 // @license MIT // @description enhance manhuagui // @author IronKinoko // @match https://www.manhuagui.com/comic/* // @icon https://www.google.com/s2/favicons?domain=manhuagui.com // @grant none // @noframes // @require https://unpkg.com/jquery@3.6.1/dist/jquery.min.js // @downloadURL https://update.greasyfork.icu/scripts/451739/manhuagui.user.js // @updateURL https://update.greasyfork.icu/scripts/451739/manhuagui.meta.js // ==/UserScript== (function () { 'use strict'; function sleep(ms) { if (!ms) { return new Promise((resolve) => { requestAnimationFrame(resolve); }); } return new Promise((resolve) => { setTimeout(resolve, ms); }); } async function wait(selector) { let bool = await selector(); while (!bool) { await sleep(); bool = await selector(); } } function isMobile() { const re = /iphone|ipad|ipod|android|webos|blackberry|windows phone/i; const ua = navigator.userAgent; return re.test(ua); } async function waitDOM(selector, root = document) { await wait(() => !!root.querySelector(selector)); return root.querySelector(selector); } var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n { document.oncontextmenu = null; createNextBtn(); createFullScreen(); if (isMobile()) { createNextBtnInH5(); } })(); async function createNextBtn() { const dom = await waitDOM(".backToTop"); const a = document.createElement("a"); a.innerHTML = "NEXT"; a.className = "k-custom-btn"; a.id = "show-next"; a.href = "javascript:;"; a.onclick = window.SMH.nextC; dom.append(a); } async function createFullScreen() { const dom = await waitDOM(".backToTop"); const a = document.createElement("a"); a.innerHTML = "FULL"; a.className = "k-custom-btn"; a.id = "full-btn"; a.href = "javascript:;"; a.onclick = () => { if (document.fullscreenElement) { document.exitFullscreen(); a.innerHTML = "FULL"; } else { document.documentElement.requestFullscreen(); a.innerHTML = "EXIT"; } }; dom.append(a); document.addEventListener("keypress", (e) => { if (document.activeElement && /textarea|input|select/i.test(document.activeElement.tagName)) { return; } if (e.key === "f") { a.click(); } }); } async function createNextBtnInH5() { const $pagination = await waitDOM("#pagination"); $pagination.innerHTML = ""; const btn = document.createElement("button"); btn.className = "big-h5-btn"; btn.textContent = "\u4E0B\u4E00\u7AE0"; btn.onclick = () => window.SMH.nextC(); $pagination.replaceWith(btn); } })();