NicePT大图

NicePT大图模式

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         NicePT大图
// @description  NicePT大图模式
// @include      *://www.nicept.net/*
// @version      0.0.1
// @run-at       document-end
// @grant         none
// @icon         https://www.nicept.net/favicon.ico
// @namespace https://greasyfork.org/users/461433
// ==/UserScript==
(function() {
    'use strict';
    //图片宽度
    let newWidth = 446;

    console.log('=== 开始检查 .embedded 元素 ===');

    // 获取所有 .embedded 元素
    let embeddedElements = document.getElementsByClassName('embedded');

    // 遍历每个 .embedded 元素
    Array.from(embeddedElements).forEach((embedded) => {
        // 获取 .embedded 元素的宽度
        let width = embedded.style.width || window.getComputedStyle(embedded).width;

        // 如果 .embedded 元素的宽度是 46px
        if (width === '46px') {
            console.log('=== 找到宽度为 46px 的 .embedded 元素 ===');

            // 获取第一个子元素(假设它是 img)
            let firstChild = embedded.children[0];

            // 判断子元素是否存在,并且是图片(img)
            if (firstChild && firstChild.tagName.toLowerCase() === 'img') {
                // 获取图片的原始宽高
                let img = firstChild;
                // 修改图片的宽度和高度
                img.style.width = newWidth + 'px';
                //img.style.height = newHeight + 'px';
                //取消max
                img.style.maxWidth = 'none';
                img.style.maxHeight = 'none';

                console.log('=== 修改了第一个元素(图片)宽度为 346px,并保持比例 ===');
            } else {
                console.log('=== 第一个子元素不是图片,跳过修改 ===');
            }
        }
    });
})();