Geotastic Helper

Helps you in the game Geotastic

当前为 2024-03-17 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Geotastic Helper
// @match       *://*.geotastic.net/*
// @grant       none
// @version     1.0
// @license GPL-3
// @author      dharmik2319
// @description Helps you in the game Geotastic
// @run-at      document-start
// @namespace getreadytoslumbeeeeeeeeeerrrrrrrrrrrrrrrrrrrr
// ==/UserScript==

window.myMap;

let map;

// Hijacking the `google` module so that we can access an initialized google.maps.Map instance
var checkInterval = setInterval(function() {
    if (typeof google === 'object' && typeof google.maps === 'object' && typeof google.maps.Map === 'function') {
        var originalMap = google.maps.Map;
        google.maps.Map = function() {
            var instance = new originalMap(...arguments);
            window.myMap = instance
            return instance
        }
        clearInterval(checkInterval); // Stop checking once the module is loaded
    }
}, 10); // Check every 10 ms


let globalCoordinates = { // keep this stored globally, and we'll keep updating it for each API call.
    lat: 0,
    lng: 0
}

var originalOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url) {
    if (url.startsWith('https://maps.googleapis.com/$rpc/google.internal.maps.mapsjs.v1.MapsJsInternalService/GetMetadata')) {
        this.addEventListener('load', function () {
            let interceptedResult = this.responseText
            let parsed = interceptedResult.replace("null","")
            const pattern = /-*\d+\.\d+,-*\d+\.\d+/g;
            let match = parsed.match(pattern)[0];
            let split = match.split(",")

            let lat = Number.parseFloat(split[0])
            let lng = Number.parseFloat(split[1])
            globalCoordinates.lat = lat
            globalCoordinates.lng = lng
            markers();
        });
    }
    // Call the original open function
    return originalOpen.apply(this, arguments);

};

function mapsFromCoords() { // opens new Google Maps location using coords.

    const {lat,lng} = globalCoordinates;
    window.open(`https://www.google.com/maps/place/${lat},${lng}`);

}
let optsMarker;
let marker;
function markers() {
  if (typeof marker!="undefined") {
    marker.setMap(null)
    marker = null
  }
  map = window.myMap
  optsMarker = {type:"drop",position:new google.maps.LatLng(globalCoordinates.lat,globalCoordinates.lng),clickable:!1,map:map,id:"test"}
  marker = new google.maps.Marker(optsMarker)

}



let onKeyDown = (e) => {
    if (e.keyCode === 50) {
	    mapsFromCoords();
    }
    if (e.keyCode === 49) {
	    alert(`${globalCoordinates.lat}, ${globalCoordinates.lng}`);
    }
}
document.addEventListener("keydown", onKeyDown);