图集岛破解VIP

破解图集岛VIP

// ==UserScript==
// @name 图集岛破解VIP
// @namespace http://tampermonkey.net/
// @version 1.5
// @description 破解图集岛VIP
// @author yyg
// @include /^https?://.*\.jimeilu.*
// @match *://*jimeilu.com/*
// @grant none
// @date 2023-06-24
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const images = document.querySelectorAll('img');

    images.forEach(image => {
        image.addEventListener('click', function(event) {
            event.preventDefault();
            const imageSrc = this.getAttribute('src');
            if (imageSrc !== null) {
                const imageSrcParts = imageSrc.split('/');
                const imageSrcBase = imageSrcParts.slice(0, -1).join('/');
                const imageSrcExt = imageSrcParts.slice(-1)[0].split('.').pop();

                // 获取兄弟节点<span>中的数字
                const a = this.parentElement;
                const span = a.nextElementSibling;
                const spanText = span.textContent.trim();
                const num = parseInt(spanText);

                // 创建新标签页
                const newWindow = window.open('about:blank', '_blank');
                newWindow.document.write('<html><body></body></html>');

                // 一次性添加num个img元素
                const imageArray = new Array(num).fill(0).map((_, i) => `${imageSrcBase}/${i+1}.${imageSrcExt}`);
                const imageElements = imageArray.map(src => {
                    const img = newWindow.document.createElement('img');
                    img.setAttribute('src', src);
                    img.style.maxWidth = '100%';
                    img.style.height = 'auto';
                    return img;
                });
                newWindow.document.body.append(...imageElements);
            }
        });
    });
})();