Google Search Maps Fix

Makes small map clickable again

2025-10-27 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Google Search Maps Fix
// @namespace    http://tampermonkey.net/
// @version      2.0.0
// @description  Makes small map clickable again
// @author       Ovinomaster
// @include      https://www.google.tld/search*
// @icon         https://www.google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png
// @grant        none
// @license      CC-BY-NC-SA-4.0; https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
// @homepageURL  https://greasyfork.org/it/users/1271103-ovinomaster
// ==/UserScript==
(function() {
    'use strict';

    function addMapsTab() {
        // Find the navigation bar container (All, Images, News…)
        const navList = document.querySelector('[role="navigation"] [role="list"]');
        if (!navList) return;

        // Check if “Maps” is already present
        const existing = Array.from(navList.querySelectorAll('li')).find(li => /Maps|Mappa/i.test(li.textContent));
        if (existing) return;

        // Clone an existing tab item to keep the same style
        const cloneSrc = navList.querySelector('li');
        if (!cloneSrc) return;

        const mapsLi = cloneSrc.cloneNode(true);
        const link = mapsLi.querySelector('a');
        if (link) {
            // Get the current search query
            const q = new URLSearchParams(window.location.search).get('q') || '';
            // Set the link to Google Maps
            link.href = `https://www.google.com/maps?q=${encodeURIComponent(q)}`;
        }
        const span = mapsLi.querySelector('span');
        if (span) {
            span.textContent = 'Maps';
        } else {
            mapsLi.textContent = 'Maps';
        }

        // Insert as the second tab (right after “All”)
        navList.insertBefore(mapsLi, navList.childNodes[1]);
    }

    function makeMiniMapClickable() {
        const q = new URLSearchParams(window.location.search).get('q') || '';
        const mapsLink = `https://www.google.com/maps?q=${encodeURIComponent(q)}`;

        // Example: thumbnails may have the “.Lx2b0d” class in Google markup
        const mini = document.querySelector('.Lx2b0d');
        if (mini && !mini.closest('a')) {
            const a = document.createElement('a');
            a.href = mapsLink;
            a.style.display = 'block';
             // Move the mini-map’s children inside the link
            while (mini.firstChild) {
                a.appendChild(mini.firstChild);
            }
            mini.appendChild(a);
        }
    }

    // Run on page load and periodically (to handle dynamic navigation)
    addMapsTab();
    makeMiniMapClickable();
    setInterval(() => {
        addMapsTab();
        makeMiniMapClickable();
    }, 2000);
})();