Greasy Fork is available in English.

Google Image "View Image" button

Добавляет кнопку просмотра изображения.

// ==UserScript==
// @name           Google Image "View Image" button
// @version        0.2
// @description    Add "View Image" button.
// @description:ru Добавляет кнопку просмотра изображения.
// @author         gvvad
// @run-at         document-end
// @include        http*://www.google.*.*/*
// @include        http*://google.*.*/*
// @include        http*://www.google.*/*
// @include        http*://google.*/*
// @grant          none
// @license        MIT; https://opensource.org/licenses/MIT
// @copyright      2019, gvvad
// @namespace      https://greasyfork.org/users/100160
// ==/UserScript==

(function() {
    'use strict';
    const ICON_SVG = '<path d="M0 0h24v24H0z" fill="none"/><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>';
    const CUSTOM_CLASS = "_goimbu";

    var link_preparator = function(node) {
        node.removeAttribute("jsaction");
        node.classList.add(CUSTOM_CLASS);
        node.src = "#";
        node.setAttribute("rel", "noreferrer");
        node.setAttribute("target", "_blank");
    }

    var obs_handler = function(mutList) {
        for (let mut of mutList) {
            try {
                //change <a href> to <img src>
                let src = mut.target.querySelector("img.irc_mi").src;
                this._a.href = src || this._a.href;
            } catch (e) {}
        }
    }

    let observer = new MutationObserver(function(mRecord) {
        for (let mutation of mRecord) {
            try {
                let prev_items = document.querySelectorAll("div.irc_c");

                for (let item of prev_items) {
                    try {
                        let shell = item.querySelector("div.irc_ab");
                        if (shell.querySelector(`a.${CUSTOM_CLASS}`)) {
                            continue;
                        }
                        let a = shell.querySelector("a.irc-flact");

                        //make copy of current button
                        let my_a = a.cloneNode(true);
                        my_a.querySelector("svg").innerHTML = ICON_SVG;
                        link_preparator(my_a);
                        shell.insertBefore(my_a, a);

                        let img = item.querySelector("img.irc_mi");
                        my_a.href = img.src;
                        let obs = new MutationObserver(obs_handler);

                        //store new button <a> node in observer object
                        obs._a = my_a;

                        //observe <img>
                        obs.observe(img.parentNode, {attributes: false, childList: true, characterData: false});
                    } catch (e) {}
                }
                //disconnect when img preview loaded
                if (prev_items.length) {
                    this.disconnect();
                }
            } catch (e) {}
        }
    });

    observer.observe(document.body, {attributes: false, childList: true, characterData: false});
})();