Skip to content

Instantly share code, notes, and snippets.

@leonbrandt
Last active November 24, 2023 19:03
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save leonbrandt/16b3a70ef70939359357c908e6b0f06d to your computer and use it in GitHub Desktop.
Save leonbrandt/16b3a70ef70939359357c908e6b0f06d to your computer and use it in GitHub Desktop.
Geoguessr cheat (Greasemonkey / Tampermonkey)
// ==UserScript==
// @name Geoguessr Cheat
// @namespace https://www.leonbrandt.com
// @version 2.0.0
// @description Press SHIFT + ALT + G and the location of your current geoguessr game will open in a new tab
// @author Leon Brandt
// @homepage https://www.leonbrandt.com
// @updateURL https://gist.githubusercontent.com/leonbrandt/16b3a70ef70939359357c908e6b0f06d/raw/geoguessr-cheat.user.js
// @match http*://*/*
// @grant none
// @run-at document-idle
// ==/UserScript==
/*
MAKE SURE TO RELOAD PAGE AFTER EVERY ROUND BEFORE PRESSING SHIFT + ALT + G
*/
function getTargetUrl() {
const raw = document.querySelectorAll("#__NEXT_DATA__")[0].text;
const json = JSON.parse(raw);
const rounds = json.props.pageProps.game.rounds;
const currentRound = rounds[rounds.length - 1];
const targetUrl = "https://google.com/maps/place/" + currentRound.lat + "," + currentRound.lng;
return targetUrl;
}
(function() {
'use strict';
document.onkeydown = evt => {
evt = evt || window.event;
if(evt.shiftKey && evt.altKey && evt.keyCode == 71){
window.open(getTargetUrl(), '_blank');
}
};
})();
@pxrple9
Copy link

pxrple9 commented Mar 4, 2021

hey, this doesn't seme to work on chromebook I had tamper monkey previously installed so I followed the instructions and installed the scripts but once im in a geo guessr game and i press SHIFT + ALT + G nothing happens

@leonbrandt
Copy link
Author

Hey @pxrple9 and @stockmecreator,

Please double-check that the userscript is loaded correctly in Tampermonkey. Also please check if reloading the page in the first round via pressing F5 already fixes the issue.

If it still doesn't work, please tell me which browser you are using and which exact game-mode you are playing.

@marcopaone
Copy link

Not work for battle royale.

@stockmecreator
Copy link

Can you do the Battle Royale version?

@leonbrandt
Copy link
Author

Can you do the Battle Royale version?

Not for now. Maybe I will try in the future.

@BobbySchurmdaButB
Copy link

Can you do the Battle Royale version?

Not for now. Maybe I will try in the future.

Yo leon could I contact you? I might have found something that could help with battle royale version

@leonbrandt
Copy link
Author

Yo leon could I contact you? I might have found something that could help with battle royale version

Sure, just PM me at Twitter: @leon_brandt

@Proa241
Copy link

Proa241 commented Mar 24, 2021

Hey MrBrandt I am using the brave browser which is based on chrome, and I am on country streak and when I press that series of keys nothing happens.

@stockmecreator
Copy link

stockmecreator commented Mar 24, 2021 via email

@bk0010bala
Copy link

Hi

this doesnt seem to work on MacBook. I am pressing Shift+Command+G since theres no Alt button and nothing seems to happen. can someone please help me on what to do

@leonbrandt
Copy link
Author

Hi

this doesnt seem to work on MacBook. I am pressing Shift+Command+G since theres no Alt button and nothing seems to happen. can someone please help me on what to do

Try using the option / key instead of command.

@JonasMArnold
Copy link

JonasMArnold commented Apr 5, 2021

May you explain where in the source code you find the long and lat data? I looked through the whole document.querySelectorAll("#__NEXT_DATA__")[0].text and wasn't able to find anything remotely helpful.. Am not implying that the code doesn't work - just curious as to what your approach is.

@leonbrandt
Copy link
Author

May you explain where in the source code you find the long and lat data? I looked through the whole document.querySelectorAll("#__NEXT_DATA__")[0].text and wasn't able to find anything remotely helpful.. Am not implying that the code doesn't work - just curious as to what your approach is.

How it's working

Obtaining the coordinates of the current round is done in this simple steps:

const raw = document.querySelectorAll("#__NEXT_DATA__")[0].text;
const json = JSON.parse(raw);
const rounds = json.props.pageProps.game.rounds;

The DOM contains an element with the id __NEXT_DATA__. This element contains text or JSON to be precise. This JSON-Object holds an array of the rounds from the current game under .props.pageProps.game.rounds. Elements in this array look like this: { lat: number, lng: number, ... }.

What my approach is / was

Just searched the DOM for something that gives a hint about the current position.

@JonasMArnold
Copy link

JonasMArnold commented Apr 7, 2021

Thanks @leonbrandt for your reply! What you described is exactly what my thought process was - though I'm still not able to locate your mentioned array, as I'll describe in the following:

The DOM contains an element with the id __NEXT_DATA__.

This is correct. In order to clear any misunderstandings - we're both talking about <script id="__NEXT_DATA__" type="application/json"> (or to be identified via the JS path: document.querySelector("#__NEXT_DATA__"))

This JSON-Object holds an array of the rounds from the current game under .props.pageProps.game.rounds

This is the point from which on our data differs. Under the main entry point props is data like middlewareResults, but there is no pageProps and thus no props.pageProps.game.rounds. I tried it via your said source code as well as via Selenium session in Python.

Any ideas on why there is a discrepancy between our two JSON trees?

//EDIT:
To be more precise as far as debugging is concerned. I'm playing the "Daily Challenge" on the map "World". When accessing your said pageProps via

# [...]
element = soup.find('script', {'id':'__NEXT_DATA__'}).text
data = json.loads(element)

pageprops = data["props"]["pageProps"]

I'll get {'statusCode': 404}, thus there exists a pageProps component with the value statuscode being 404 (=denied). Furthermore, even checking manually I can't find game within pageProps.

@leonbrandt
Copy link
Author

Hello @JonasMArnold,

Furthermore, even checking manually I can't find game within pageProps.

I was able to replicate this observation in the daily challenge. The object game seems to only exist in the normal gamemode. Thus limiting the support of this script for the daily challenge.

Currently my approach is the only working one known to me. For this reason this script isn't working for the battle royale mode too. Obviously it seems to be very limited.

@Proa241
Copy link

Proa241 commented Jun 15, 2021

Dont work

@leonbrandt
Copy link
Author

leonbrandt commented Jun 16, 2021

Dont work

Care to explain in more detail what didn't work so I have a chance to fix it?
What exact steps did you do until you observed your problem? What do you expect to happen and what happend instead?

Copy link

ghost commented Sep 27, 2021

Hey there, a couple of months ago there was a link to another thread, which showed a working script for battle royale in geoguessr, but I can't find it anymore. Could you help me find it again?

@geoquizzer
Copy link

geoquizzer commented Oct 11, 2021

EDIT: User error! It does work.

Original comment:
doesn't work with the new geoguessr - not even on the classic games

@alphor12
Copy link

alphor12 commented Jan 4, 2022

Is it possible to manipulate this script so that it opens the page on a second monitor?
Also, is it possible to manipulate the script so that you don't need to reload?
Thank you!

@leonbrandt
Copy link
Author

Is it possible to manipulate this script so that it opens the page on a second monitor?

Yes it is. If you are familiar with Javascript you can check out this. I'm not planning to implement an exhaustive feature for monitor-selection at this moment - maybe if I have more time for it.

Also, is it possible to manipulate the script so that you don't need to reload?

Unfortunately not. I don't have any other solution than that.

@TurtleRade
Copy link

I made some changes to this script to work in battle royale. I gave you credits. Here is the link https://github.com/TurtleRade/geoguessrbattletoyalecheat

@tcortega
Copy link

tcortega commented Feb 2, 2022

Hello fellow comrades 😄

Found this gist a few hours ago and it made me want to create my own version, which will work in multiple game modes. And here it is:
https://gist.github.com/tcortega/7378d20dcfa7d15df780032ca2b78b3d

It has the same keybind as this cheat, but it works for Duels, Streaks, Battle-royales and Challenges. And you don't have to reload.
Hope you all like it:smile_cat:

Copy link

ghost commented Jun 17, 2022

Can I get a ban for it?

@Xarond12
Copy link

hello, i'm looking for drawing location on map script. I had something like that but by mistake i removed it

@kisames
Copy link

kisames commented Sep 28, 2022

still works?

@Kein187
Copy link

Kein187 commented Oct 16, 2022

still work?

@LiquIDMeowz
Copy link

does not work

@101cohen
Copy link

Any way you could make it so the tab opens on the other monitor?

@Ivre31
Copy link

Ivre31 commented Feb 26, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment