Google Search Maps Fix

Bring Google maps button back

2024-03-06 기준 버전입니다. 최신 버전을 확인하세요.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Google Search Maps Fix
// @namespace    http://tampermonkey.net/
// @version      2024-03-06
// @description  Bring Google maps button back
// @author       Daan Grashoff / Delivator
// @match        https://www.google.*/search
// @icon         https://www.google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    function addMapsLink() {
        // Find the existing results tabs (Images, News, etc.)
        const tabsContainer = document.querySelector('.IUOThf');
        const mapImage = document.querySelector('#lu_map');

        // Get the search query from the URL
        const searchQuery = new URLSearchParams(window.location.search).get('q');

        // Construct the Maps link with the query
        const mapsLink = `${window.location.origin}/maps?q=${searchQuery}`;

        // If map image exists
        if (mapImage) {
            const anchorElement = document.createElement('a');
            anchorElement.href = mapsLink;
            mapImage.parentNode.insertBefore(anchorElement, mapImage);
            anchorElement.appendChild(mapImage);
        }

        // If tabs exist, proceed
        if (tabsContainer) {
            // Create the Maps button
            const mapsButton = document.createElement('a');
            mapsButton.classList.add('nPDzT', 'T3FoJb');  // Style to match other tabs

            // Create the inner elements for the Maps button
            const mapDiv = document.createElement('div');
            mapDiv.jsname = 'bVqjv';
            mapDiv.classList.add('GKS7s');

            const mapSpan = document.createElement('span');
            mapSpan.classList.add('FMKtTb', 'UqcIvb');
            mapSpan.jsname = 'pIvPIe';
            mapSpan.textContent = 'Maps';

            // Assemble the elements
            mapDiv.appendChild(mapSpan);
            mapsButton.appendChild(mapDiv);
            mapsButton.href = mapsLink;

            // Insert the Maps button at the beginning of the tabs container
            tabsContainer.prepend(mapsButton);
        }

    }

    // Call the function to add the button
    addMapsLink();

})();