OpenGuessr Hack Location Finder

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

当前为 2024-12-05 提交的版本,查看 最新版本

// ==UserScript==
// @name         OpenGuessr Hack Location Finder
// @namespace    https://openguessr.com/
// @version      2.0
// @description  Extract and open PanoramaIframe location 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();

    // Function to handle the key combination
    function handleKeyCombination() {
        if (keysPressed.has('control') && keysPressed.has('x') && keysPressed.has('s')) {
            console.log('Control + X + S detected.');

            // Locate the iframe element by its ID
            const iframe = document.querySelector('#PanoramaIframe');
            if (iframe) {
                const src = iframe.getAttribute('src');
                if (src) {
                    try {
                        // Parse the URL to extract the location parameter
                        const url = new URL(src);
                        const location = url.searchParams.get('location'); // Extract "LAT,LONG"
                        if (location) {
                            // Open the full Google Maps URL
                            const mapsUrl = `https://www.google.com/maps?q=${location}`;
                            console.log('Opening URL:', mapsUrl);
                            window.open(mapsUrl, '_blank');
                        } else {
                            console.error('Location parameter not found in iframe URL.');
                        }
                    } catch (error) {
                        console.error('Error parsing iframe URL:', error);
                    }
                } else {
                    console.error('Iframe src attribute not found.');
                }
            } else {
                console.error('Iframe with ID "PanoramaIframe" not found.');
            }

            // Prevent default browser behavior
            keysPressed.clear();
        }
    }

    // Event listener for keydown
    document.addEventListener('keydown', (event) => {
        keysPressed.add(event.key.toLowerCase());
        console.log('Key down:', event.key);

        // Handle the key combination
        handleKeyCombination();
    });

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

    // Add an invisible focus-capturing layer over the iframe
    const iframe = document.querySelector('#PanoramaIframe');
    if (iframe) {
        const overlay = document.createElement('div');
        overlay.style.position = 'absolute';
        overlay.style.top = `${iframe.offsetTop}px`;
        overlay.style.left = `${iframe.offsetLeft}px`;
        overlay.style.width = `${iframe.offsetWidth}px`;
        overlay.style.height = `${iframe.offsetHeight}px`;
        overlay.style.zIndex = '10';
        overlay.style.pointerEvents = 'none'; // Allow clicks to pass through
        document.body.appendChild(overlay);

        overlay.addEventListener('mouseenter', () => {
            window.focus(); // Refocus the parent window
        });
    }

    // Reset keys when the window loses focus
    window.addEventListener('blur', () => {
        console.log('Window lost focus, clearing keys.');
        keysPressed.clear();
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址