Search with google image fix

Search with google image again cause fuck google lens

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Search with google image fix
// @namespace    http://tampermonkey.net/
// @version      1.1.4
// @description  Search with google image again cause fuck google lens
// @author       You
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// @match        http://*/*
// @match        https://*/*
// @exclude      https://www.instant-gaming.com/*
// @grant        none
// ==/UserScript==

var invert = true;

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);
}

(function() {

    GM_addStyle(`
.container__menu {
                /* Absolute position */
                position: absolute;

                /* Reset */
                list-style: none;
                margin: 0;
                padding: 0;
                display: none;

                /* Misc */
                border: 1px solid #cbd5e0;
                border-radius: 0.25rem;
                background-color: #f7fafc;
            }
`);


    GM_addStyle(`
    .open {
    display: block;
    z-index: 9999;
}
`);

    GM_addStyle(`
.container__item {
                padding: 0.5rem 1rem;
                white-space: nowrap;
                cursor: pointer;
    color: black;
            }
`);

    GM_addStyle(`
 .container__item:hover {
                background-color: #bee3f8;
            }
`);

    GM_addStyle(`
.container__divider {
                border-bottom: 1px solid #cbd5e0;
                height: 1px;
            }
`);


    $("body").append(`
    <ul id="fucklens" class="container__menu">
                    <li class="container__item">Search with google image</li>
                </ul>
                `);

    var cntxtMn = $("#fucklens");
    var mouseX;
    var mouseY;
    var currentTarget = null;

    $(document).mousemove(function(e) {
        mouseX = e.pageX;
        mouseY = e.pageY;
    });
    $("img").on('contextmenu', displayContextMenu);


    const observer = new MutationObserver(function(mutations_list) {
        mutations_list.forEach(function(mutation) {
            mutation.addedNodes.forEach(function(added_node) {
                var img = $(added_node).find("img");
                if (img){
                    img.on('contextmenu', displayContextMenu);
                }
            });
        });
    });

    observer.observe(document, { subtree: true, childList: true });

    //thank you for this guy https://jsfiddle.net/JCJDesigns/6zsvmt10/
    function displayContextMenu(e) {
        (cntxtMn.hasClass("open")) ? cntxtMn.removeClass("open") : false;
        /*
         If inverte is true then ctrl key = special menu
         if invert is false then ctrl key = skip

        */
        if (invert == false && e.ctrlKey)
            return;

        else if (e.ctrlKey && invert)
        {
            cntxtMn.css({'top':mouseY,'left':mouseX}).addClass("open");
            e.preventDefault();
            currentTarget = e.target;
            return;
        }
        else if (invert == false){
            cntxtMn.css({'top':mouseY,'left':mouseX}).addClass("open");
            e.preventDefault();
            currentTarget = e.target;
        }

    }
    cntxtMn.click(function(e) {
        e.stopPropagation();
    });

    $(document).click(function() {
        (cntxtMn.hasClass("open")) ? cntxtMn.removeClass("open") : false;
    });

    $(".container__item").click(function(){
        var src = "https://lens.google.com/uploadbyurl?url=" + $(currentTarget).prop("src");
        console.log($(currentTarget).prop("src"));
        (cntxtMn.hasClass("open")) ? cntxtMn.removeClass("open") : false;
        window.open(src);
    });


})();