嗨皮漫画 方向鍵控制上一話與下一話

使用左右方向鍵控制上一話與下一話的切換

当前为 2025-08-13 提交的版本,查看 最新版本

// ==UserScript==
// @name         嗨皮漫画 方向鍵控制上一話與下一話
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  使用左右方向鍵控制上一話與下一話的切換
// @author       shanlan(ChatGPT o3-mini)
// @match        https://m.happymh.com/mangaread/*
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    function isEditable(el) {
        return el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.isContentEditable;
    }
    function navigateChapter(e) {
        if (isEditable(e.target)) return;
        let targetButton = null;
        let buttons = document.querySelectorAll('button[data-href]');
        if (e.keyCode === 37) {
            buttons.forEach(function(btn) {
                if (btn.textContent.indexOf("上一話") > -1 || btn.textContent.indexOf("上一话") > -1) {
                    targetButton = btn;
                }
            });
        } else if (e.keyCode === 39) {
            buttons.forEach(function(btn) {
                if (btn.textContent.indexOf("下一話") > -1 || btn.textContent.indexOf("下一话") > -1) {
                    targetButton = btn;
                }
            });
        } else {
            return;
        }
        if (targetButton) {
            let href = targetButton.getAttribute('data-href');
            if (href) {
                window.location.href = href;
            } else {
                targetButton.click();
            }
        }
    }
    window.addEventListener('keydown', navigateChapter, false);
})();

QingJ © 2025

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