成人交流 · text · 0 分 · 评论 0

写了一个油猴脚本,修复老番号剧情截图不显示的问题

本帖最後由 极品女优收藏家 於 2026-6-18 00:09 編輯

【最终修改版来了,代码重新修改,放大了图床切换按钮,使其更加醒目,因为看新番号的人多,所以默认使用网站的原图床,如果老番号图片不显示的话,点击上方的图床切换按钮,即可显示老番的剧情截图。】

最新在看番号的过程中,发现很多番号下的剧情截图不显示,而且有好几个不显示图片的原因,有提示NOW PRINTING的,有提示The image could not be loaded.的,研究了下,应该是网站几次版本变动,老的大图的图床链接代码没有改过来,我给JAV-JHS油猴脚本的作者留了言,原本是想让它在脚本中增加这个功能的,但也不知道他会不会看到,有没有时间改,所以干脆自己写了个单独修复剧情截图的脚本,测试了下,成功显示,以ABW-124为例,修复效果如图。所以发出来给需要的人们。

没安装油猴的去谷歌应用商店搜篡改猴,安装后点击油猴插件,下拉菜单中选择管理面板,点击已安装脚本旁边的+加号,将代码复制进去,选择编辑器下方的文件,保存即可。
代码如下,从下方开始复制:
// ==UserScript==
// @name         JavBus 剧情截图不显示修复 V3
// @namespace    javbus-sample-fix
// @version      7.0
// @description  自动修复JavBus样品图失效问题(仅处理带-番号)
// @author       ChatGPT
// @match        https://www.javbus.com/*
// @icon         https://52afd5e.webp.li/ICON-16.png
// @icon         https://52afd5e.webp.li/ICON-32.png
// @icon64       https://52afd5e.webp.li/ICON-64.png
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    //------------------------------------
    // 获取番号
    //------------------------------------
    function getMovieCode() {
        let code = null;
        const text = document.body.innerText;
        const match = text.match(/識別碼[::]\s*([A-Z]+-\d+)/i);
        if (match) {
            code = match[1];
        }
        if (!code) {
            const path = location.pathname.split('/').pop();
            if (/^[A-Z]+-\d+$/i.test(path)) {
                code = path;
            }
        }
        return code;
    }

    //------------------------------------
    // 生成MGStage大图URL
    //------------------------------------
    function buildImageUrl(code, index) {
        const lower = code.toLowerCase();
        const parts = lower.split('-');
        if (parts.length !== 2) return null;
        const letters = parts[0];
        const numbers = parts[1];
        return `https://image.mgstage.com/images/prestige/${letters}/${numbers}/cap_e_${index}_${lower}.jpg`;
    }

    //------------------------------------
    // 获取样品图
    //------------------------------------
    function getSampleImages() {
        const imgs = [];
        document.querySelectorAll('#sample-waterfall a img').forEach(img => {
            imgs.push(img);
        });
        if (imgs.length === 0) {
            document.querySelectorAll('.sample-box img').forEach(img => {
                imgs.push(img);
            });
        }
        return imgs;
    }

    //------------------------------------
    // 获取原始大图URL(从页面元素中提取)
    //------------------------------------
    function getOriginalImageUrl(index) {
        const imgs = getSampleImages();
        if (imgs[index]) {
            const link = imgs[index].closest('a');
            if (link && link.href) {
                return link.href;
            }
        }
        return null;
    }

    //------------------------------------
    // 隐藏网站原有的弹窗UI元素
    //------------------------------------
    function hideOriginalPopupUI() {
        // 隐藏关闭按钮
        const closeBtn = document.querySelector('.mfp-close');
        if (closeBtn) {
            closeBtn.style.display = 'none';
        }

        // 隐藏左右箭头
        const prevBtn = document.querySelector('.mfp-arrow-left');
        const nextBtn = document.querySelector('.mfp-arrow-right');
        if (prevBtn) {
            prevBtn.style.display = 'none';
        }
        if (nextBtn) {
            nextBtn.style.display = 'none';
        }
    }

    //------------------------------------
    // 创建弹窗
    //------------------------------------
    function createViewer(urls, startIndex, originalUrl) {
        let current = startIndex;
        let usingMGStage = false;
        let currentOriginalUrl = originalUrl;

        const overlay = document.createElement('div');
        overlay.id = 'mgstage-fix-viewer';

        overlay.innerHTML = `
            <div class="viewer-close">✕</div>
            <div class="viewer-restore" id="viewer-restore-btn">切换MGStage图床【老番号图片不显示时使用】</div>
            <div class="viewer-prev">❮</div>
            <img class="viewer-image">
            <div class="viewer-next">❯</div>
        `;

        document.body.appendChild(overlay);

        // 隐藏网站原有的弹窗UI
        hideOriginalPopupUI();

        const img = overlay.querySelector('.viewer-image');
        const restoreBtn = overlay.querySelector('#viewer-restore-btn');

        function show(index) {
            if (index < 0) {
                index = urls.length - 1;
            }
            if (index >= urls.length) {
                index = 0;
            }
            current = index;

            if (usingMGStage) {
                img.src = urls[current];
            } else {
                const origUrl = getOriginalImageUrl(current);
                if (origUrl) {
                    img.src = origUrl;
                    currentOriginalUrl = origUrl;
                }
            }

            updateRestoreButton();
        }

        function updateRestoreButton() {
            if (usingMGStage) {
                restoreBtn.textContent = '切换默认图床';
                restoreBtn.style.background = '#e53935';
            } else {
                restoreBtn.textContent = '切换MGStage图床【老番号图片不显示时使用】';
                restoreBtn.style.background = '#4CAF50';
            }
        }

        restoreBtn.onclick = (e) => {
            e.stopPropagation();
            if (usingMGStage) {
                usingMGStage = false;
                const origUrl = currentOriginalUrl || getOriginalImageUrl(current);
                if (origUrl) {
                    img.src = origUrl;
                }
            } else {
                usingMGStage = true;
                img.src = urls[current];
            }
            updateRestoreButton();
        };

        overlay.querySelector('.viewer-close').onclick = () => {
            overlay.remove();
        };

        overlay.querySelector('.viewer-prev').onclick = (e) => {
            e.stopPropagation();
            show(current - 1);
        };

        overlay.querySelector('.viewer-next').onclick = (e) => {
            e.stopPropagation();
            show(current + 1);
        };

        overlay.onclick = e => {
            if (e.target === overlay) {
                overlay.remove();
            }
        };

        document.addEventListener('keydown', function esc(e) {
            if (!document.getElementById('mgstage-fix-viewer')) {
                document.removeEventListener('keydown', esc);
                return;
            }
            if (e.key === 'Escape') {
                overlay.remove();
            }
            if (e.key === 'ArrowLeft') {
                show(current - 1);
            }
            if (e.key === 'ArrowRight') {
                show(current + 1);
            }
        });

        show(startIndex);

        return {
            show
        };
    }

    //------------------------------------
    // 样式
    //------------------------------------
    function injectStyle() {
        const style = document.createElement('style');
        style.textContent = `
        #mgstage-fix-viewer{
            position:fixed;
            left:0;
            top:0;
            width:100%;
            height:100%;
            background:rgba(0,0,0,.9);
            z-index:999999;
            display:flex;
            justify-content:center;
            align-items:center;
        }

        #mgstage-fix-viewer .viewer-image{
            max-width:92%;
            max-height:92%;
        }

        #mgstage-fix-viewer .viewer-close{
            position:absolute;
            right:20px;
            top:10px;
            font-size:40px;
            color:white;
            cursor:pointer;
        }

        #mgstage-fix-viewer .viewer-restore{
            position:absolute;
            top:120px;
            left:50%;
            transform:translateX(-50%);
            background:#4CAF50;
            color:#fff;
            border:none;
            padding:15px 35px;
            border-radius:8px;
            font-size:20px;
            font-weight:bold;
            cursor:pointer;
            z-index:10;
            white-space:nowrap;
            box-shadow:0 4px 20px rgba(0,0,0,0.6);
        }

        #mgstage-fix-viewer .viewer-restore:hover{
            background:#45a049;
            transform:translateX(-50%) scale(1.05);
        }

        #mgstage-fix-viewer .viewer-prev,
        #mgstage-fix-viewer .viewer-next{
            position:absolute;
            top:50%;
            transform:translateY(-50%);
            font-size:60px;
            color:white;
            cursor:pointer;
            user-select:none;
            padding:10px 20px;
        }

        #mgstage-fix-viewer .viewer-prev{
            left:20px;
        }

        #mgstage-fix-viewer .viewer-next{
            right:20px;
        }
        `;
        document.head.appendChild(style);
    }

    //------------------------------------
    // 主逻辑
    //------------------------------------
    function init() {
        const code = getMovieCode();
        if (!code) {
            return;
        }

        const imgs = getSampleImages();
        if (!imgs.length) {
            return;
        }

        const urls = imgs.map((_, index) => {
            return buildImageUrl(code, index);
        });

        imgs.forEach((img, index) => {
            const link = img.closest('a');
            if (!link) return;

            const originalUrl = link.href;

            link.addEventListener('click', function (e) {
                e.preventDefault();
                e.stopPropagation();

                const old = document.getElementById('mgstage-fix-viewer');
                if (old) {
                    old.remove();
                }

                const viewer = createViewer(urls, index, originalUrl);
                viewer.show(index);
            }, true);
        });

        console.log('[JavBus MGStage Fix] 已接管样品图像,默认使用原始图床');
    }

    injectStyle();
    window.addEventListener('load', () => {
        setTimeout(init, 1000);
    });

})();複製代碼







评论 (0)

登录 后参与讨论。

还没有评论,来抢沙发吧。