Saved place note: Ctrl+Enter to submit

Ctrl+Enter to submit on the popup for adding a note to a saved place.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Saved place note: Ctrl+Enter to submit
// @description  Ctrl+Enter to submit on the popup for adding a note to a saved place.
// @namespace    https://github.com/nate-kean/
// @version      20251020
// @author       Nate Kean
// @match        https://www.google.com/maps*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant        none
// @license      MIT
// ==/UserScript==

(async function() {
    function delay(ms) {
        return new Promise((resolve) => setTimeout(resolve, ms));
    }

    async function waitForElement(selector, pollingRateMs=100, parent=document) {
        let el;
        while (true) {
            el = parent.querySelector(selector);
            if (el) return el;
            await delay(pollingRateMs);
        }
    }

    async function elementGone(selector, pollingRateMs=100, parent=document) {
        let el;
        while (true) {
            el = parent.querySelector(selector);
            if (!el) return;
            await delay(pollingRateMs);
        }
    }


    while (true) {
        const el = await waitForElement("textarea.sbPorb.gRsCne.azQIhc");
        el.addEventListener("keypress", (evt) => {
            if (evt.keyCode === 10 && evt.ctrlKey) {
                document.querySelector("button.okDpye.PpaGLb.mta2Ab").click();
            }
        });
        await elementGone("textarea.sbPorb.gRsCne.azQIhc");
    }
})();