fix Google image popup

show images in popup instead of opening the source

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         fix Google image popup
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  show images in popup instead of opening the source
// @author       You
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// @include      https://www.google.*
// @grant        none
// ==/UserScript==

function GM_addStyle(css) {
    const style = document.getElementById("GM_addStyle") || (function() {
        const style = document.createElement('style');
        style.type = 'text/css';
        style.id = "GM_addStyle";
        document.head.appendChild(style);
        return style;
    })();
    const sheet = style.sheet;
    sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
}
GM_addStyle('.fixmodal {position:fixed;background-color:rgba(0, 0, 0, 0.5);height:100%;width:100%;top:0;left:0;display:none; z-index: 1000;}');
GM_addStyle('#fixPopup {padding:5px;text-align:center;}');
GM_addStyle('.fixmodalWrap {margin:5% auto; position:relative;width: fit-content;} ');

(function() {
    'use strict';
    var test = window.screen.height - 400;
GM_addStyle('#fixPopup img {max-height:'+test+'px;max-width:100%}');
    var callbackRoot = function(mutationsList, observer) {
        for(var mutation of mutationsList) {
            mutation.addedNodes.forEach(function(node) {
                if ($(node).find(".v4dQwb")){
                    var imageNode = $(node).find(".v4dQwb");
                    if (imageNode.hasClass("fixAttached") == false){
                        imageNode.addClass("fixAttached");
                        imageNode.click(function(e){
                            var thisImgSrc = $(this).find("img").attr("src");
                            e.stopPropagation();
                            $(".fixmodal").fadeIn("fast");
                            $("#fixPopup img").remove();
                            $('<img src="'+thisImgSrc+'" alt="image3" />').appendTo("#fixPopup");
                            e.preventDefault();
                        });
                    }
                }
            });
        }
    };
    function attachObserver(){
        var obs = $('.T1diZc');
        var isReady = obs.length > 0;
        if (!isReady) {
            setTimeout(obs, 300);
            return;
        }
        $("body").append('<div class="fixmodal"> <div class="fixmodalWrap"><div id="fixPopup"></div> </div></div>');
        $(document).on("click", function () {
            $(".fixmodal").fadeOut("fast");
        });
        $(".modalWrap").on("click", function (e) {
            e.stopPropagation();
        });
        console.log("attaching");
        var config = { attributes: false, childList: true, subtree: true };
        var targetNodeRoot = $(obs).first().get(0);
        var observerroot = new MutationObserver(callbackRoot);
        observerroot.observe(targetNodeRoot, config);
    }
    attachObserver();
})();