WorldGuessr Coordinate Finder

Adds a button to get latitude and longitude in WorldGuessr and copy it to clipboard, plus a minimap when coordinates are available

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

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.

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

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

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 WorldGuessr Coordinate Finder
// @namespace http://tampermonkey.net/
// @version 1.5
// @description Adds a button to get latitude and longitude in WorldGuessr and copy it to clipboard, plus a minimap when coordinates are available
// @author Projectornist
// @license NO REDISTRIBUTION OR ELSE
// @match https://www.worldguessr.com/*
// @grant GM_addStyle
// ==/UserScript==

(function() {
  'use strict';

  GM_addStyle(`
    #getCoordsButton {
      position: fixed;
      top: 20px;
      right: 20px;
      padding: 10px 20px;
      background-color: black;
      color: white;
      border: none;
      border-radius: 5px;
      font-size: 16px;
      cursor: pointer;
      z-index: 9999;
    }
    #getCoordsButton:hover {
      background-color: #333;
    }
    #coordsDisplay {
      position: fixed;
      top: 70px;
      right: 20px;
      padding: 10px;
      background-color: rgba(0, 0, 0, 0.7);
      color: white;
      border-radius: 5px;
      font-size: 14px;
      display: none;
      z-index: 9999;
    }
    #googleMapContainer {
      position: fixed;
      bottom: 20px;
      left: 20px;
      width: 300px;
      height: 300px;
      background-color: rgba(0, 0, 0, 0.8);
      border-radius: 10px;
      overflow: hidden;
      display: none;
      z-index: 9999;
    }
    #googleMapContainer iframe {
      width: 100%;
      height: 100%;
      border: none;
    }
    #googleMapContainer .closeBtn {
      position: absolute;
      top: 10px;
      right: 10px;
      background-color: #333;
      color: white;
      padding: 5px;
      cursor: pointer;
    }
  `);

  if (document.getElementById('getCoordsButton')) {
    return;
  }

  const button = document.createElement('button');
  button.id = 'getCoordsButton';
  button.textContent = 'Get Coordinates';
  document.body.appendChild(button);

  const coordsDisplay = document.createElement('div');
  coordsDisplay.id = 'coordsDisplay';
  document.body.appendChild(coordsDisplay);

  const mapContainer = document.createElement('div');
  mapContainer.id = 'googleMapContainer';
  document.body.appendChild(mapContainer);

  const closeBtn = document.createElement('button');
  closeBtn.textContent = 'X';
  closeBtn.className = 'closeBtn';
  mapContainer.appendChild(closeBtn);

  function getCoordinates() {
    const urlParams = new URLSearchParams(window.location.search);
    const lat = urlParams.get('lat');
    const long = urlParams.get('long');

    if (lat && long) {
      coordsDisplay.textContent = `Latitude: ${lat}, Longitude: ${long}`;
      coordsDisplay.style.display = 'block';
      showMinimap(lat, long);
      copyToClipboard(`${lat}, ${long}`);
    } else {
      coordsDisplay.textContent = 'Coordinates not found';
      coordsDisplay.style.display = 'block';
    }
  }

  function copyToClipboard(text) {
    navigator.clipboard.writeText(text).then(() => {
    }).catch(err => {
    });
  }

  function showMinimap(lat, long) {
    const iframe = document.createElement('iframe');
    iframe.src = `https://www.google.com/maps?q=${lat},${long}&z=18&output=embed`;

    mapContainer.style.display = 'block';

    mapContainer.appendChild(iframe);

    closeBtn.onclick = () => {
      mapContainer.style.display = 'none';
      mapContainer.innerHTML = '';
      mapContainer.appendChild(closeBtn);
    };
  }

  function checkCoordinatesAvailability() {
    const urlParams = new URLSearchParams(window.location.search);
    const lat = urlParams.get('lat');
    const long = urlParams.get('long');

    if (lat && long) {
      button.style.display = 'inline-block';
    } else {
      button.style.display = 'none';
    }
  }

  setInterval(checkCoordinatesAvailability, 1000);

  button.addEventListener('click', function() {
    getCoordinates();
  });

})();