Greasy Fork镜像 支持简体中文。

Add Esc key on Google Maps

Add Esc key on Google Maps for better UX.

目前為 2021-07-07 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Add Esc key on Google Maps
// @namespace   https://github.com/gslin/add-esc-key-on-google-maps
// @match       https://www.google.com/maps*
// @grant       none
// @version     0.20210707.1
// @author      Gea-Suan Lin <[email protected]>
// @description Add Esc key on Google Maps for better UX.
// @license     MIT
// ==/UserScript==

(() => {
    'use strict';

    window.addEventListener('keydown', ev => {
        // Esc key
        if (27 === ev.keyCode) {
            // User page.
            let el = document.querySelector('button[aria-label="Close"], button[aria-label="關閉"]');
            if (el && el.offsetHeight > 0 && el.offsetWidth > 0) {
                el.click();
                return;
            }

            // Comment page.
            el = document.querySelector('button[aria-label="Back"], button[aria-label="返回"]');
            if (el && el.offsetHeight > 0 && el.offsetWidth > 0) {
                el.click();
                return;
            }

            // Store page.
            el = document.querySelector('a[guidedhelpid="clear_search"]');
            if (el && el.offsetHeight > 0 && el.offsetWidth > 0) {
                el.click();
                return;
            }
        }
    }, true);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址