Created
February 18, 2021 11:55
-
-
Save redex557/d6c1a481de7e2bc7c33d0f71690f12e6 to your computer and use it in GitHub Desktop.
Geoguessr Battle Royale Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Geoguessr Bot | |
// @version 1.0.0 | |
// @description level up your geoguessr battle royale account | |
// @author Maxxx | |
// @require https://cdn.jsdelivr.net/gh/bigdatacloudapi/js-reverse-geocode-client@latest/bigdatacloud_reverse_geocode.min.js | |
// @match https://www.geoguessr.com/* | |
// @grant GM_xmlhttpRequest | |
// ==/UserScript== | |
function getTargetUrl() { | |
const raw = document.querySelectorAll("#__NEXT_DATA__")[0].text; | |
const json = JSON.parse(raw); | |
const rounds = json.props.pageProps.game.rounds; | |
console.log(rounds); | |
const currentRound = rounds[rounds.length - 1]; | |
const targetUrl = "https://google.com/maps/place/" + currentRound.lat + "," + currentRound.lng; | |
return targetUrl; | |
} | |
function getLat(d) { | |
const json = JSON.parse(d); | |
const rounds = json.rounds; | |
const currentRound = rounds[rounds.length - 1]; | |
return currentRound.lat; | |
} | |
function getLng(d) { | |
const json = JSON.parse(d); | |
const rounds = json.rounds; | |
const currentRound = rounds[rounds.length - 1]; | |
return currentRound.lng; | |
} | |
function getRound(d) { | |
const json = JSON.parse(d); | |
const round = json.currentRoundNumber; | |
return round; | |
} | |
function getToken() { | |
const raw = document.querySelectorAll("#__NEXT_DATA__")[0].text; | |
const json = JSON.parse(raw); | |
const token = json.query.token; | |
return token; | |
} | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
(function() { | |
'use strict'; | |
var reverseGeocoder=new BDCReverseGeocode(); | |
var roundn = 0; | |
var guessr = function () { | |
let done = Array.from(document.getElementsByClassName("popup-view__header")).find(e => e.innerText.includes('qualified')); | |
if (done){ | |
console.log("done here"); | |
} | |
if (!done){ | |
function $(d) { return document.getElementById(d); } | |
roundn += 1; | |
GM_xmlhttpRequest({ | |
method: "post", | |
url: "https://game-server.geoguessr.com/api/battle-royale/"+getToken()+"/guess", | |
headers: { "Content-type" : "application/json" }, | |
data: "{\"countryCode\":\"in\",\"roundNumber\":"+roundn+"}", | |
onload: function(e) { //console.log(e) | |
console.log("Send india guess for round "+getRound(e.responseText)); | |
/* Get the administrative location information using a set of known coordinates */ | |
reverseGeocoder.getClientLocation({ | |
latitude: getLat(e.responseText), | |
longitude: getLng(e.responseText), | |
},async function(result) { | |
console.log(result.countryCode); | |
await sleep(3000); | |
GM_xmlhttpRequest({ | |
method: "post", | |
url: "https://game-server.geoguessr.com/api/battle-royale/"+getToken()+"/guess", | |
headers: { "Content-type" : "application/json" }, | |
data: "{\"countryCode\":\""+result.countryCode.toLowerCase()+"\",\"roundNumber\":"+getRound(e.responseText)+"}", | |
onload: function(f){ console.log("Send guess for round "+getRound(e.responseText)+" : "+result.countryCode.toLowerCase()); | |
roundn = getRound(e.responseText); | |
} | |
}); | |
}); | |
} | |
});} | |
}; | |
var restarter = function () { | |
let but = Array.from(document.getElementsByClassName("button button--medium button--ghost")).find(e => e.textContent === 'Play again'); | |
if(but){ | |
but.click(); | |
} | |
}; | |
window.setInterval(guessr, 10000); | |
window.setInterval(restarter, 30000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
only reason thats ever happened to me was it just got stuck and refreshing and waiting a second would fix it. Ive won soooooooo many game with that thing. There are a couple of key binds for different functions in that one. One is like display where one is guess for you and another is open good maps.