OpenGuessr Location Button

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

Από την 03/05/2025. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         OpenGuessr Location Button
// @namespace    https://openguessr.com/
// @version      1.0
// @description  This Script Adds A Green Button: 🔍 Show Location At The Top Of Your Screen On The Right Side.
// @author       Sev
// @match        https://openguessr.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    function createLocationButton() {
        const existing = document.querySelector('#openGuessrLocationButton');
        if (existing) return; 

        const btn = document.createElement('button');
        btn.textContent = '🔍 Show Location';
        btn.id = 'openGuessrLocationButton';
        btn.style.position = 'fixed';
        btn.style.top = '20px';
        btn.style.right = '20px';
        btn.style.zIndex = '9999';
        btn.style.padding = '10px 15px';
        btn.style.backgroundColor = '#2c7';
        btn.style.color = 'white';
        btn.style.border = 'none';
        btn.style.borderRadius = '5px';
        btn.style.cursor = 'pointer';
        btn.style.fontSize = '16px';
        btn.style.boxShadow = '0 2px 6px rgba(0,0,0,0.2)';

        btn.onclick = () => {
            const iframe = document.querySelector('#PanoramaIframe');
            if (!iframe) {
                alert('Panorama iframe not found. Make sure a round is active.');
                return;
            }

            const src = iframe.getAttribute('src');
            if (!src) {
                alert('Iframe has no source URL.');
                return;
            }

            try {
                const url = new URL(src);
                const location = url.searchParams.get('location');
                if (location) {
                    const mapsUrl = `https://www.google.com/maps?q=${location}`;
                    window.open(mapsUrl, '_blank');
                } else {
                    alert('No location found in iframe URL.');
                }
            } catch (err) {
                alert('Error parsing iframe URL.');
                console.error(err);
            }
        };

        document.body.appendChild(btn);
    }

    const observer = new MutationObserver(() => {
        const iframe = document.querySelector('#PanoramaIframe');
        if (iframe) {
            createLocationButton();
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true,
    });

    window.addEventListener('load', () => {
        setTimeout(() => {
            const iframe = document.querySelector('#PanoramaIframe');
            if (iframe) createLocationButton();
        }, 1000);
    });
})();