您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add Esc key on Google Maps for better UX.
当前为
- // ==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.20210101.2
- // @author Gea-Suan Lin <gslin@gslin.org>
- // @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 (works only in traditional chinese environment).
- let el = document.querySelector('button[aria-label="關閉"]');
- if (el && el.offsetHeight > 0 && el.offsetWidth > 0) {
- el.click();
- return;
- }
- // Comment page (works only in traditional chinese environment).
- el = document.querySelector('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);
- })();