ImageViewer

图片查看效果增强 for Chrome/Edge/Firefox ( 基于:https://www.tampermonkey.net )

Verze ze dne 13. 07. 2021. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         ImageViewer
// @namespace    http://fulicat.com
// @url          https://greasyfork.org/zh-CN/scripts/429054-imageviewer
// @version      1.0.7
// @description  图片查看效果增强 for Chrome/Edge/Firefox  ( 基于:https://www.tampermonkey.net )
// @author       Jack.Chan ([email protected])
// @match        *://*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    if (document.contentType.startsWith('image/')) {
        var doc = document.body || document.documentElement;
        var docTagName = (function(tag){
                var tagName = tag && tag.tagName.toLowerCase();
                if (tagName) {
                    if (tagName == 'svg') {
                        return tagName;
                    }
                    if (tagName == 'body' && tag.children && tag.children.length) {
                        tagName = tag.children[0].tagName.toLowerCase();
                        if (tagName == 'img') {
                            return tagName;
                        }
                    }
                }
        })(doc);
        var isViewerMode = docTagName == 'svg' || docTagName == 'img';
        if (isViewerMode) {
            console.log('@ImageViewer');
            if (document.head) {
                var style = document.createElement('style');
                style.setAttribute('type', 'text/css');
                style.innerHTML = `img{position: static !important;background: none !important;background-color: transparent !important;}`;
                document.head.appendChild(style);
            }
            doc.style.backgroundImage = 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ1IDc5LjE2MzQ5OSwgMjAxOC8wOC8xMy0xNjo0MDoyMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTkgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjUwODBCOTRFREZCNDExRUI5ODVFQkZDMUFFOUU5Q0FBIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjUwODBCOTRGREZCNDExRUI5ODVFQkZDMUFFOUU5Q0FBIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NTA4MEI5NENERkI0MTFFQjk4NUVCRkMxQUU5RTlDQUEiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NTA4MEI5NERERkI0MTFFQjk4NUVCRkMxQUU5RTlDQUEiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4S9mZgAAAAY0lEQVR42uzYUQkAIAxFURUDLMr6p1oEU0wUzg0wOLy/zcwcnVVV6/01Pg8AAAAAAAAAAAAAAAAAAAAAAAAAAADgfrv7fx8RFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAB4qyPAAIoqBuJ7WIoBAAAAAElFTkSuQmCC)';
            doc.style.backgroundAttachment = 'fixed';
            doc.style.boxSizing = 'border-box';
            doc.style.position = 'absolute';
            doc.style.top = '50%';
            doc.style.left = '50%';
            doc.style.transform = 'translate(-50%, -50%)';
            if (docTagName == 'svg') {
                doc.style.padding = '10px';
                doc.style.width = 'auto';
                doc.style.height = 'auto';
                doc.style.maxWidth = '100%';
                doc.style.maxHeight = '100%';
            }
        }
    }
})();