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

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

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

// ==UserScript==
// @name         看漫畫&漫畫人 手機版 - 新增頁數跳轉功能
// @namespace    http://tampermonkey.net/
// @version      1.2.3
// @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 darkStyle = "appearance:none;-webkit-appearance:none;-moz-appearance:none;font-size:13px;line-height:1;height:20px;vertical-align:middle;padding:0 4px;margin-right:2px;border:1px solid #444;border-radius:3px;background:#000;color:#fff;background-image:none;";
if(location.hostname.indexOf("manhuaren.com") !== -1){
  const label = document.querySelector("#lbcurrentpage");
  if(!label) return;
  const titleP = label.closest(".view-fix-top-bar-title");
  if(!titleP) return;
  const m = titleP.textContent.match(/\/\s*(\d+)\s*$/);
  const total = m ? +m[1] : 0;
  if(!total) return;
  const current = parseInt(label.textContent,10) || 1;
  const s = document.createElement("select");
  s.style.cssText = darkStyle;
  for(let i=1;i<=total;i++) s.add(new Option(i, i));
  s.value = current;
  s.onchange = () => {
    let v = +s.value; v = Math.max(1, Math.min(total, v));
    label.textContent = v;
    const pm = location.pathname.match(/^\/m(\d+)(?:-p\d+)?\/?$/);
    if(pm){
      const id = pm[1];
      const path = v === 1 ? `/m${id}/` : `/m${id}-p${v}/`;
      location.href = location.origin + path + location.search;
    } else {
      location.reload();
    }
  };
  label.parentNode.insertBefore(s, label);
  label.style.display = "none";
  return;
}
const $ = s => document.querySelector(s), init = () => {
  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 = darkStyle;
  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或关注我们的公众号极客氢云获取最新地址