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

在漫畫閱讀頁面(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/*
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function(){
  'use strict';
  const $=s=>document.querySelector(s);
  const init=()=>{
    // 原本為 #pageNo 與 .manga-page,這裡增加 manhuaren 的備援選取器
    const n = $('#pageNo') || $('#lbcurrentpage');
    const w = document.querySelector('.manga-page') || document.querySelector('.view-fix-top-bar-title');
    if(!n||!w) return;
    // 先嘗試原本的 "/ ... P" 形式,若不行再嘗試一般 "/22" 這種形式
    const totalMatch = w.textContent.match(/\/\s*(\d+)\s*P/i) || w.textContent.match(/\/\s*(\d+)\b/);
    const total = (totalMatch && totalMatch[1]) ? (+totalMatch[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();
  };
  document.readyState==='loading'?addEventListener('DOMContentLoaded',init,{once:true}):init();
})();

QingJ © 2025

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