Extract and open PanoramaIframe location in Google Maps full site when pressing Control + X + S together
当前为
// ==UserScript==
// @name OpenGuessr Hack Location Finder
// @namespace https://openguessr.com/
// @version 1.5
// @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();
// Event listener for keydown
document.addEventListener('keydown', (event) => {
keysPressed.add(event.code); // Use event.code for precise key detection
// Check if ControlLeft, KeyX, and KeyS are pressed simultaneously
if (keysPressed.has('ControlLeft') && keysPressed.has('KeyX') && keysPressed.has('KeyS')) {
// 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}`;
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
event.preventDefault();
}
});
// Event listener for keyup to clear pressed keys
document.addEventListener('keyup', (event) => {
keysPressed.delete(event.code); // Remove the released key
});
})();