OpenGuessr Hack Location Finder

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

Pada tanggal 01 Desember 2024. Lihat %(latest_version_link).

  1. // ==UserScript==
  2. // @name OpenGuessr Hack Location Finder
  3. // @namespace https://openguessr.com/
  4. // @version 1.8
  5. // @description Extract and open PanoramaIframe location in Google Maps full site when pressing Control + X + S together
  6. // @author Duolingo
  7. // @license MIT
  8. // @match https://openguessr.com/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. // Track pressed keys
  16. let controlPressed = false;
  17. let xPressed = false;
  18. let sPressed = false;
  19.  
  20. // Add an event listener to capture keydown events globally (even when interacting with the iframe)
  21. document.addEventListener('keydown', (event) => {
  22. // Check if the keypress is for control, x, or s
  23. if (event.key === 'Control') controlPressed = true;
  24. if (event.key === 'x') xPressed = true;
  25. if (event.key === 's') sPressed = true;
  26.  
  27. // When all three keys are pressed, execute the action
  28. if (controlPressed && xPressed && sPressed) {
  29. // Locate the iframe element by its ID
  30. const iframe = document.querySelector('#PanoramaIframe');
  31. if (iframe) {
  32. const src = iframe.getAttribute('src');
  33. if (src) {
  34. try {
  35. // Parse the URL to extract the `location` parameter
  36. const url = new URL(src);
  37. const location = url.searchParams.get('location'); // Extract "LAT,LONG"
  38. if (location) {
  39. // Open the full Google Maps URL
  40. const mapsUrl = `https://www.google.com/maps?q=${location}`;
  41. window.open(mapsUrl, '_blank');
  42. } else {
  43. console.error('Location parameter not found in iframe URL.');
  44. }
  45. } catch (error) {
  46. console.error('Error parsing iframe URL:', error);
  47. }
  48. } else {
  49. console.error('Iframe src attribute not found.');
  50. }
  51. } else {
  52. console.error('Iframe with ID "PanoramaIframe" not found.');
  53. }
  54.  
  55. // Prevent default browser behavior
  56. event.preventDefault();
  57.  
  58. // Reset keys after action
  59. controlPressed = false;
  60. xPressed = false;
  61. sPressed = false;
  62. }
  63. });
  64.  
  65. // Add an event listener to capture keyup events globally (to clear flags)
  66. document.addEventListener('keyup', (event) => {
  67. if (event.key === 'Control') controlPressed = false;
  68. if (event.key === 'x') xPressed = false;
  69. if (event.key === 's') sPressed = false;
  70. });
  71.  
  72. // Force the focus back on the document to ensure the key press is always detected
  73. window.addEventListener('blur', () => {
  74. // Reset all key states when window loses focus
  75. controlPressed = false;
  76. xPressed = false;
  77. sPressed = false;
  78. });
  79.  
  80. })();