Google Maps Image Downloader

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

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

Advertisement:

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

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

})();