妖火图片加强(改)

妖火图片加强!!! 改 烟花小神 的

目前为 2024-05-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         妖火图片加强(改)
// @namespace    http://yaohuo.me/
// @version      0.21
// @description  妖火图片加强!!! 改 烟花小神 的
// @require      https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js
// @match        https://yaohuo.me/bbs-**
// @match        https://www.yaohuo.me/bbs-**
// @icon         https://www.google.com/s2/favicons?sz=64&domain=yaohuo.me
// @author       夜猎
// ==/UserScript==

(function() {
    'use strict';

    $(document).ready(function() {
        var defaultImgSize = 100;
        var maxPreviewSize = 9999;

        var imageContainer = document.createElement('div');
        imageContainer.classList.add('imageContainer');
        imageContainer.style.display = 'none';
        imageContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
        imageContainer.style.borderRadius = '10px';
        imageContainer.style.position = 'fixed';
        imageContainer.style.top = '50%';
        imageContainer.style.left = '50%';
        imageContainer.style.transform = 'translate(-50%, -50%)';
        imageContainer.style.zIndex = '9999';
        imageContainer.style.padding = '20px';
        document.body.appendChild(imageContainer);

        var imageElement = document.createElement('img');
        imageElement.style.maxWidth = maxPreviewSize + 'px';
        imageElement.style.maxHeight = maxPreviewSize + 'px';
        imageContainer.appendChild(imageElement);

        function wheelHandler(event) {
            event.preventDefault();
            var currentWidth = parseFloat(imageElement.style.width) || imageElement.width;
            var scaleFactor = event.deltaY > 0 ? 0.9 : 1.1;
            var newWidth = currentWidth * scaleFactor;
            imageElement.style.width = newWidth + 'px';
            imageElement.style.height = 'auto';
        }

        var thirdImages = document.querySelectorAll('.content img');

        for (var i = 0; i < thirdImages.length; i++) {
            var thirdImage = thirdImages[i];
            thirdImage.style.maxHeight = '780px';
            if (thirdImage.parentNode.tagName == 'A' && thirdImage.parentNode.href.indexOf('https://yaohuo.me/bbs/upload/') == 0) {
                thirdImage.parentNode.onclick = function() {
                    return false;
                };
            }

            thirdImage.onclick = function() {
                debugger;
                var isZoomed = imageContainer.style.display !== 'none';

                // 使用toggle函数根据当前样式来决定添加还是移除max-height属性
                if (this.style.maxHeight) {
                    this.style.maxHeight = null; // 移除max-height
                } else {
                    this.style.maxHeight = '780px'; // 添加max-height
                    var distanceToTop = this.offsetTop;
                    // 计算新的滚动位置,使图片位于视口偏下150px处
                    var newScrollPosition = distanceToTop + 150;
                     window.scrollTo({
                         top: newScrollPosition,
                         behavior: "smooth"
                     });
                    //this.scrollIntoView({behavior: "smooth"});
                }
            };
        }
    });
})();

QingJ © 2025

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