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

目前為 2025-04-03 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name WorldGuessr Coordinate Finder
// @namespace http://tampermonkey.net/
// @version 1.3
// @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 You can modify as long as you credit me
// @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();
  });

})();