OpenGuessr Location Button

This Script Adds A Green Button: 🔍 Show Location At The Top Of Your Screen On The Right Side.

  1. // ==UserScript==
  2. // @name OpenGuessr Location Button
  3. // @namespace https://openguessr.com/
  4. // @version 1.0
  5. // @description This Script Adds A Green Button: 🔍 Show Location At The Top Of Your Screen On The Right Side.
  6. // @author Sev
  7. // @match https://openguessr.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. function createLocationButton() {
  16. const existing = document.querySelector('#openGuessrLocationButton');
  17. if (existing) return;
  18.  
  19. const btn = document.createElement('button');
  20. btn.textContent = '🔍 Show Location';
  21. btn.id = 'openGuessrLocationButton';
  22. btn.style.position = 'fixed';
  23. btn.style.top = '20px';
  24. btn.style.right = '20px';
  25. btn.style.zIndex = '9999';
  26. btn.style.padding = '10px 15px';
  27. btn.style.backgroundColor = '#2c7';
  28. btn.style.color = 'white';
  29. btn.style.border = 'none';
  30. btn.style.borderRadius = '5px';
  31. btn.style.cursor = 'pointer';
  32. btn.style.fontSize = '16px';
  33. btn.style.boxShadow = '0 2px 6px rgba(0,0,0,0.2)';
  34.  
  35. btn.onclick = () => {
  36. const iframe = document.querySelector('#PanoramaIframe');
  37. if (!iframe) {
  38. alert('Panorama iframe not found. Make sure a round is active.');
  39. return;
  40. }
  41.  
  42. const src = iframe.getAttribute('src');
  43. if (!src) {
  44. alert('Iframe has no source URL.');
  45. return;
  46. }
  47.  
  48. try {
  49. const url = new URL(src);
  50. const location = url.searchParams.get('location');
  51. if (location) {
  52. const mapsUrl = `https://www.google.com/maps?q=${location}`;
  53. window.open(mapsUrl, '_blank');
  54. } else {
  55. alert('No location found in iframe URL.');
  56. }
  57. } catch (err) {
  58. alert('Error parsing iframe URL.');
  59. console.error(err);
  60. }
  61. };
  62.  
  63. document.body.appendChild(btn);
  64. }
  65.  
  66. const observer = new MutationObserver(() => {
  67. const iframe = document.querySelector('#PanoramaIframe');
  68. if (iframe) {
  69. createLocationButton();
  70. }
  71. });
  72.  
  73. observer.observe(document.body, {
  74. childList: true,
  75. subtree: true,
  76. });
  77.  
  78. window.addEventListener('load', () => {
  79. setTimeout(() => {
  80. const iframe = document.querySelector('#PanoramaIframe');
  81. if (iframe) createLocationButton();
  82. }, 1000);
  83. });
  84. })();