看漫畫&漫畫人 手機版 - 新增頁數跳轉功能

在漫畫閱讀頁面(Manhuagui & manhuaren ),將右上角頁碼改為下拉選單,選取即跳轉到指定頁。

目前為 2025-09-17 提交的版本,檢視 最新版本

// ==UserScript==
// @name         看漫畫&漫畫人 手機版 - 新增頁數跳轉功能
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  在漫畫閱讀頁面(Manhuagui & manhuaren ),將右上角頁碼改為下拉選單,選取即跳轉到指定頁。
// @author       shanlan(ChatGPT GPT-5)
// @match        https://m.manhuagui.com/comic/*
// @match        https://www.manhuaren.com/*
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function(){
  'use strict';
  const $=s=>document.querySelector(s);
  const init=()=>{
    if(location.hostname==='m.manhuagui.com'){
      const n=$('#pageNo'), w=$('.manga-page');
      if(!n||!w) return;
      const total=(w.textContent.match(/\/\s*(\d+)\s*P/i)||[])[1]|0;
      if(!total) return;
      const gh=()=>{const m=location.hash.match(/(?:^|#|&)p=(\d+)/);return m?+m[1]:NaN;};
      const h=gh(), cur=Number.isInteger(h)?h:(parseInt(n.textContent)||1);
      const s=document.createElement('select');
      s.style.cssText='font-size:15px;line-height:1;height:22px;vertical-align:middle;padding:0 6px;margin-right:2px;border:1px solid #ccc;border-radius:4px;background:#fff;';
      for(let i=1;i<=total;i++) s.add(new Option(i,i));
      s.value=cur;
      s.onchange=()=>{
        let v=+s.value; v=Math.max(1,Math.min(total,v));
        n.textContent=v;
        const nh='#p='+v;
        if(location.hash===nh) dispatchEvent(new HashChangeEvent('hashchange')); else location.hash=nh;
      };
      n.before(s); n.style.display='none';
      const sync=()=>{
        const x=gh(); if(!Number.isInteger(x)) return;
        const v=Math.max(1,Math.min(total,x)), t=String(v);
        if(s.value!==t) s.value=t;
        if(n.textContent!==t) n.textContent=t;
      };
      addEventListener('hashchange',sync);
      sync();
    } else if(location.hostname==='www.manhuaren.com'){
      const label = $('#lbcurrentpage');
      if(!label) return;
      const title = $('.view-fix-top-bar-title');
      if(!title) return;
      const match = title.textContent.match(/\/(\d+)/);
      if(!match) return;
      const total = parseInt(match[1]);
      if(!total) return;
      const cur = parseInt(label.textContent) || 1;
      const s = document.createElement('select');
      s.style.cssText='font-size:15px;line-height:1;height:22px;vertical-align:middle;padding:0 6px;margin-right:8px;border:1px solid #ccc;border-radius:4px;background:#fff;';
      for(let i=1; i<=total; i++) s.add(new Option(i,i));
      s.value = cur;
      s.onchange = ()=>{
        let v = +s.value; v = Math.max(1, Math.min(total, v));
        label.textContent = v;
        const href = location.href.replace(/(\d+)(?=\/?$)/, v);
        if(href !== location.href) location.href = href;
      };
      label.parentNode.insertBefore(s, label);
      label.style.display = 'none';
    }
  };
  document.readyState==='loading'?addEventListener('DOMContentLoaded',init,{once:true}):init();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址