OpenGuessr Hack Location Finder

Extract and open PanoramaIframe src in Google Maps full site when pressing Control + X + S together

Verze ze dne 01. 12. 2024. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         OpenGuessr Hack Location Finder
// @namespace    https://openguessr.com/
// @version      1.3
// @description  Extract and open PanoramaIframe src in Google Maps full site when pressing Control + X + S together
// @author       YourName
// @license      MIT
// @match        https://openguessr.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Track pressed keys
    const keysPressed = new Set();

    // Event listener for keydown
    document.addEventListener('keydown', (event) => {
        // Add the pressed key to the set
        keysPressed.add(event.key.toLowerCase());

        // Check if Control, X, and S keys are pressed
        if (keysPressed.has('control') && keysPressed.has('x') && keysPressed.has('s')) {
            // Find the iframe element by ID
            const iframe = document.querySelector('#PanoramaIframe');
            if (iframe) {
                const src = iframe.getAttribute('src');
                if (src) {
                    // Parse the URL to extract parameters
                    const url = new URL(src);
                    const latLng = url.searchParams.get('pb')?.split('!')[2]; // Extracts "place" data
                    if (latLng) {
                        const [latitude, longitude] = latLng.split(',');
                        // Open the full Google Maps URL in a new tab
                        const mapsUrl = `https://www.google.com/maps/@${latitude},${longitude},15z`;
                        window.open(mapsUrl, '_blank');
                    } else {
                        console.error('Latitude and longitude could not be extracted');
                    }
                } else {
                    console.error('Iframe src attribute not found');
                }
            } else {
                console.error('Iframe with ID "PanoramaIframe" not found');
            }

            // Prevent default behavior
            event.preventDefault();
        }
    });

    // Event listener for keyup to clear the pressed key
    document.addEventListener('keyup', (event) => {
        keysPressed.delete(event.key.toLowerCase());
    });
})();