GeoGuessr Map Maker lat/lng

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

  1. // ==UserScript==
  2. // @name GeoGuessr Map Maker lat/lng
  3. // @namespace ggmmll
  4. // @description Display the current lat/lng in the GeoGuessr Map Maker, can be locked with a right click
  5. // @version 0.4
  6. // @match https://www.geoguessr.com/*
  7. // @require https://openuserjs.org/src/libs/xsanda/Run_code_as_client.js
  8. // @require https://openuserjs.org/src/libs/xsanda/Google_Maps_Promise.js
  9. // @run-at document-start
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. googleMapsPromise.then(() => runAsClient(() => {
  14. const google = window.google;
  15.  
  16. var flag = false
  17.  
  18. function getPositionDiv() {
  19. if (location.pathname.includes("/map-maker/")) {
  20. let mmm = document.querySelector("[class^=top-bar_topMenu_]")
  21. if (mmm) {
  22. let position = document.querySelector("[data-name=position]")
  23. if (!position) {
  24. position = document.createElement("div")
  25. position.dataset.name = "position"
  26. position.style = "color: var(--ds-color-white-80); font-size: var(--font-size-14); font-weight: 400; line-height: var(--line-height-14); margin: .5rem; text-align: center"
  27. mmm.insertBefore(position, mmm.children[1]);
  28. }
  29. return position
  30. }
  31. }
  32. }
  33.  
  34. function displayCoordinates(ev) {
  35. let position = getPositionDiv()
  36. if (position && !flag) {
  37. position.innerText = Math.round(ev.latLng.lat() * 10000) / 10000 + "," + Math.round(ev.latLng.lng() * 10000) / 10000
  38. }
  39. }
  40.  
  41. window.addEventListener("load", (event) => {
  42. getPositionDiv()
  43. });
  44.  
  45. const oldMap = google.maps.Map;
  46. google.maps.Map = Object.assign(function (...args) {
  47. const res = oldMap.apply(this, args);
  48. this.addListener('mousemove', displayCoordinates);
  49. this.addListener('rightclick', () => {flag = !flag});
  50. return res;
  51. }, {
  52. prototype: Object.create(oldMap.prototype)
  53. });
  54. }));