GeoGuessr Map Maker lat/lng

Display the current lat/lng in the GeoGuessr Map Maker, can be locked with a right click

Устаревшая версия за 18.10.2022. Перейдите к последней версии.

// ==UserScript==
// @name GeoGuessr Map Maker lat/lng
// @namespace   ggmmll
// @description Display the current lat/lng in the GeoGuessr Map Maker, can be locked with a right click
// @version 0.2
// @match https://www.geoguessr.com/*
// @require https://openuserjs.org/src/libs/xsanda/Run_code_as_client.js
// @require https://openuserjs.org/src/libs/xsanda/Google_Maps_Promise.js
// @run-at document-start
// @license MIT
// ==/UserScript==

googleMapsPromise.then(() => runAsClient(() => {
    const google = window.google;

    var flag = false

    function displayCoordinates(ev) {
        let mmm = document.querySelector("[class^=map-maker-map_map]")
        if (mmm) {
            let position = document.getElementById("position")
            if (!position) {
                position = document.createElement("div")
                position.id = "position"
                position.style = "position: relative; text-align: center; pointer-events: none; color: black"
                mmm.firstChild.firstChild.appendChild(position)
            }

            if (!flag) {
                position.innerText = ev.latLng.lat() + "," + ev.latLng.lng()
            }
        }
    }

    const oldMap = google.maps.Map;
    google.maps.Map = Object.assign(function (...args) {
        const res = oldMap.apply(this, args);
        this.addListener('mousemove', displayCoordinates);
        this.addListener('rightclick', () => {flag = !flag});
        return res;
    }, {
        prototype: Object.create(oldMap.prototype)
    });
}));