-
-
Save tcortega/7378d20dcfa7d15df780032ca2b78b3d to your computer and use it in GitHub Desktop.
// ==UserScript== | |
// @name Geoguessr AIO Cheat | |
// @namespace https://github.com/tcortega | |
// @version 1.0.1 | |
// @description Press SHIFT + ALT + G and the location of your current geoguessr game will open in a new tab | |
// @author tcortega | |
// @homepage https://github.com/tcortega | |
// @downloadURL https://gist.github.com/tcortega/7378d20dcfa7d15df780032ca2b78b3d/raw/geoguessr-aio.user.js | |
// @updateURL https://gist.github.com/tcortega/7378d20dcfa7d15df780032ca2b78b3d/raw/geoguessr-aio.user.js | |
// @match http*://*/* | |
// @grant none | |
// @run-at document-idle | |
// ==/UserScript== | |
function getCleanUrl() { | |
return window.location.href.replace("/reconnect", "").replace("?client=web", ""); | |
} | |
function getJsonData() { | |
const rawData = document.querySelector("pre").innerText; | |
return JSON.parse(rawData); | |
} | |
function apiUrlToGameUrl() { | |
const apiUrl = getCleanUrl(); | |
return apiUrl.replace("game-server.", "").replace("/api", "").replace("/v3", "").replace(""); | |
} | |
function getGameMode(url) { | |
return url.split(".com/")[1].split("/")[0].toUpperCase(); | |
} | |
function getApiUrl(url, gamemode) { | |
url = url.replace("www.", ""); | |
switch (gamemode) { | |
case "DUELS": | |
case "TEAM-DUELS": | |
case "BATTLE-ROYALE": { | |
return url.replace("geoguessr.com", "game-server.geoguessr.com/api").replace("team-duels", "duels"); | |
} | |
case "COMPETITIVE-STREAK": { | |
return url.replace("geoguessr.com/competitive-streak", "game-server.geoguessr.com/api/competitive-streaks"); | |
} | |
case "GAME": { | |
return url.replace("geoguessr.com/game", "geoguessr.com/api/v3/games"); | |
} | |
} | |
} | |
function isApiPage() { | |
return getCleanUrl().includes("/api/"); | |
} | |
function makeApiCall(apiUrl) { | |
window.open(apiUrl, "_blank"); | |
} | |
function handleChallenge() { | |
const raw = document.querySelectorAll("#__NEXT_DATA__")[0].text; | |
const json = JSON.parse(raw); | |
const rounds = json.props.pageProps.game.rounds; | |
const { lat, lng } = rounds[rounds.length - 1]; | |
openMaps({ lat, lng }, "_blank"); | |
} | |
function handleKeyEvent() { | |
const url = getCleanUrl(); | |
const gameMode = getGameMode(url); | |
if (gameMode == "CHALLENGE") return handleChallenge(); | |
const apiUrl = getApiUrl(url, gameMode); | |
makeApiCall(apiUrl); | |
} | |
function formatDuelsResponse(jsonData) { | |
const rounds = jsonData.rounds.map((r) => ({ lat: r.panorama.lat, lng: r.panorama.lng })); | |
return { round: jsonData.currentRoundNumber, rounds }; | |
} | |
function formatStreaksResponse(jsonData) { | |
const rounds = [jsonData.player.currentRound]; | |
return { round: 1, rounds }; | |
} | |
function formatBattleRoyaleResponse({ currentRoundNumber, rounds }) { | |
return { round: currentRoundNumber, rounds }; | |
} | |
function formatGameResponse({ round, rounds }) { | |
return { round, rounds }; | |
} | |
function formatResponse(gameMode) { | |
const jsonData = getJsonData(); | |
if (gameMode == "DUELS"|| gameMode == "TEAM-DUELS") return formatDuelsResponse(jsonData); | |
if (gameMode == "COMPETITIVE-STREAKS") return formatStreaksResponse(jsonData); | |
if (gameMode == "BATTLE-ROYALE") return formatBattleRoyaleResponse(jsonData); | |
if (gameMode == "GAMES") return formatGameResponse(jsonData); | |
} | |
function getLocation(gameMode) { | |
const { round, rounds } = formatResponse(gameMode); | |
const currentRound = rounds[round - 1]; | |
return { lat: currentRound.lat, lng: currentRound.lng }; | |
} | |
function openMaps(location, target = "_self") { | |
const mapUrl = `https://google.com/maps/place/${location.lat},${location.lng}`; | |
window.open(mapUrl, target); | |
} | |
function handleApiPage() { | |
const gameUrl = apiUrlToGameUrl(); | |
const gameMode = getGameMode(gameUrl); | |
const location = getLocation(gameMode); | |
openMaps(location); | |
} | |
(function () { | |
"use strict"; | |
if (!getCleanUrl().includes("geoguessr.com")) return; // Just in case | |
if (isApiPage()) { | |
return handleApiPage(); | |
} | |
// TO-DO: Refactor this so it does not have to figure out which game mode is being used each time the user issues the command (lazy to do rn). | |
document.onkeydown = (evt) => { | |
evt = evt || window.event; | |
if (evt.shiftKey && evt.altKey && evt.keyCode == 71) { | |
handleKeyEvent(); | |
} | |
}; | |
})(); |
@tcortega How to change the code so that a new window appears?
I also made a discord server for anyone who are interested in developing new cheat: https://discord.gg/spMdRF8Sku
Yo could you get another link for that? I would like to join
Hello, I have a small question. How can we make the new map page replace the old one?
hey @Ptorioo i saw your cheat got removed from github and greasy fork, can you post the same one if you can please?
hello, i'm looking for drawing location on map script. I had something like that but by mistake i removed it
HOW DO YOU DO IT ON MAC???? PLEASE HELP? the shift + alt + g is not on mac (shift)?? where to get?
All the keyboards have a shift. What is your problem?
Doesnt work today in duels - in BR its work. WTF ?
Confirmed Patched for Duels ( location takes you to Alcatraz every time ). Still working in Battle Royale.
This script somehow doesn't work anymore. I made my own working version combined with averman's script: https://github.com/Ptorioo/Geoguessr-Disunity-Script
Competitive Streak is somewhat buggy but I cba to fix it as no one actually plays that anymore lol. Feel free to fix it if anyone is interested.