Google Maps Image Downloader

الحصول على رابط الصورة في خرائط Google

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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.

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

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

Advertisement:

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.

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

Advertisement:

// ==UserScript==
// @name         Google Maps Image Downloader
// @namespace    https://tampermonkey.net/
// @version      1.0
// @description  الحصول على رابط الصورة في خرائط Google
// @match        https://www.google.com/maps/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let currentImageUrl = null;

    // تلتقط أحدث صورة معروضة
    function updateCurrentImage() {
        const imgs = [...document.querySelectorAll('img[src*="googleusercontent.com"]')];

        if (!imgs.length) return;

        // Google Maps يعرض عدة صور، عادةً الصورة الأكبر هي الصورة الحالية
        let largestImg = imgs[0];
        let maxSize = 0;

        imgs.forEach(img => {
            const size = img.naturalWidth * img.naturalHeight;
            if (size > maxSize) {
                maxSize = size;
                largestImg = img;
            }
        });

        currentImageUrl = largestImg.src;
    }

    // زر فتح الصورة الأصلية
    function createButton() {
        if (document.getElementById("gm-full-image-btn")) return;

        const btn = document.createElement("button");
        btn.id = "gm-full-image-btn";
        btn.innerText = "فتح الصورة";
        btn.style.position = "fixed";
        btn.style.top = "20px";
        btn.style.left = "20px";
        btn.style.zIndex = "9999999";
        btn.style.padding = "10px 15px";
        btn.style.background = "#34A853";
        btn.style.color = "white";
        btn.style.border = "none";
        btn.style.borderRadius = "5px";
        btn.style.cursor = "pointer";

        btn.onclick = () => {
            updateCurrentImage(); // ← أهم نقطة
            if (!currentImageUrl) return alert("لم يتم العثور على صورة.");

            const fullUrl = currentImageUrl.replace(/=w\d+.*/, "=w0");
            window.open(fullUrl, "_blank");
        };

        document.body.appendChild(btn);
    }

    // راقب الصور وتعرّف على الصورة الحالية باستمرار
    function observeImages() {
        const observer = new MutationObserver(() => {
            updateCurrentImage();
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true,
            attributes: true,
            attributeFilter: ["src"]
        });
    }

    window.addEventListener("load", () => {
        createButton();
        observeImages();

        // تحديث أولي
        setTimeout(updateCurrentImage, 2000);
    });

})();