Mozilla-Image-Viewer

Modify the default jump view method for Mozilla document images to the current page preview

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Mozilla-Image-Viewer
// @description  Modify the default jump view method for Mozilla document images to the current page preview
// @include      http*
// @version      1.0.0
// @author       Eilen https://github.com/EilenC
// @grant        none
// @match        https://developer.mozilla.org/*
// @namespace    https://greatest.deepsurf.us/users/319354
// @supportURL   https://github.com/EilenC/Tampermonkey-Scripts/blob/master/MozillaDocumentImageViewer/viewer.js
// @icon         https://www.google.com/s2/favicons?sz=64&domain=mozilla.org
// @license      GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';

    // 等待页面完全加载后执行
    window.addEventListener('load', function() {
        var images = document.querySelectorAll('img');

        // 移除图片外层的链接
        images.forEach(function(img) {
            var link = img.parentNode;
            if (link.tagName.toLowerCase() === 'a') {
                var parent = link.parentNode;
                parent.insertBefore(img, link);
                parent.removeChild(link);
            }
        });

        // 为所有图片添加点击缩放功能
        function zoomImage(img) {
            // 创建覆盖层元素
            var overlay = document.createElement('div');
            overlay.style.position = 'fixed';
            overlay.style.top = '0';
            overlay.style.left = '0';
            overlay.style.width = '100%';
            overlay.style.height = '100%';
            overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.7)'; // 修改背景颜色为半透明黑色
            overlay.style.display = 'flex';
            overlay.style.justifyContent = 'center';
            overlay.style.alignItems = 'center';
            overlay.style.zIndex = '9999';

            // 创建图片元素
            var zoomedImg = document.createElement('img');
            zoomedImg.src = img.src;
            zoomedImg.style.maxWidth = '90%';
            zoomedImg.style.maxHeight = '90%';
            overlay.appendChild(zoomedImg);

            // 添加到文档
            document.body.appendChild(overlay);

            // 点击事件处理
            overlay.onclick = function() {
                document.body.removeChild(overlay);
            };
        }

        images.forEach(function(img) {
            img.onclick = function() {
                zoomImage(this);
            };
        });
    });
})();