Greasy Fork is available in English.

Bring back Google Maps button

Bring back Google Maps button in search results

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

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

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

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

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

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

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

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

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

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

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

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

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

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

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Bring back Google Maps button
// @namespace    http://tampermonkey.net/
// @version      2024-02-13
// @description  Bring back Google Maps button in search results
// @author       You
// @match        https://www.google.com/*
// @match        https://google.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function addMapsButton() {
        // Find the existing results tabs container (Images, News, etc.)
        const listItemsContainer = document.querySelector('[role="navigation"] [role="list"]');

        // Give up if the container wasn't found
        if (!listItemsContainer) {
            return
        }

        // Find a sibling item that is not selected to steal stuff from

        const listItems = listItemsContainer.querySelectorAll('[role="listitem"]');

        const siblingItem = Array.from(listItems).find((item) => !item.querySelector('div[selected]'));

        // Maps item

        const mapsItem = siblingItem.cloneNode(true)

        const searchQuery = new URLSearchParams(window.location.search).get('q');

        mapsItem.querySelector('a').href = `http://maps.google.com/maps?q=${searchQuery}`;

        mapsItem.querySelector('span').textContent = 'Maps';

        // Insert the Maps button after "All" results

        listItemsContainer.insertBefore(mapsItem, listItemsContainer.childNodes[1]);
    }

    // Call the function to add the button
    addMapsButton();
})();