Skip to content

Instantly share code, notes, and snippets.

@moglerdev
Created August 1, 2023 09:36
Show Gist options
  • Save moglerdev/46668dcbcae37a6f164d845a0706497e to your computer and use it in GitHub Desktop.
Save moglerdev/46668dcbcae37a6f164d845a0706497e to your computer and use it in GitHub Desktop.
A small bot to cheat in the balloon game from echometer
/**
* Shootbot for Echometer
*/
class SB {
websocket = null;
constructor() {
const retroId = window.location.pathname.split("/").at(-1);
this.xsrfToken = document.cookie.split(";").map(x => x.trim().split("=")).filter(x => x[0].toLowerCase() == "xsrf-token")[0][1];
this.websocket = new WebSocket(`wss://my.echometerapp.com/api/retro/${retroId}/events?isMobile=false`);
this.websocket.addEventListener("open", () => {
console.log("websocket opened");
this.auth();
});
// this.websocket.addEventListener("message", (event) => {
// // console.log("websocket message", event);
// });
this.websocket.addEventListener("error", (event) => {
console.log("websocket error");
});
this.websocket.addEventListener("close", () => {
console.log("websocket closed");
});
}
/**
* List of all running bots (window.bots)
*/
get bots() {
return window.bots || (window.bots = []);
}
bloop() {
const botObj = JSON.stringify({"@type":"event","payload":{"type":"CheckoutBalloonShot"}});
this.websocket.send(botObj);
}
startBot(ms = 10, packetSize = 10) {
return setInterval(() => {
for (let i = 0; i < packetSize; i++) {
this.bloop();
}
}, ms);
}
auth() {
const authObj = JSON.stringify({
"xsrfToken": this.xsrfToken,
"enabledFeatureFlags":["GoogleLogin","RetroTemplatesClickForDetailsHint","LanguageSwitcherTemplatePage","ShowOnboardingModal","SkipToRetroBoard","PLGQuestion","PLGCheckIn","ForceEventTracking"]
})
this.websocket.send(authObj);
}
/**
* Send a packet of 10 CheckoutBalloonShot events every 1ms
* @param {string} retroId current id of the retro (found in the url)
* @param {string} xsrfToken current xsrfToken (found in the cookies or websocket)
* @returns the id (interval id) of the current bot
*/
start() {
const id = this.startBot();
this.bots.push(id);
return id;
}
/**
* Stop all running bots
*/
stop() {
this.bots.forEach(bot => clearInterval(bot));
}
}
/*
TO START
*/
const x = new SB();
// x.start() // To start the bot
// x.stop() // To stop the bot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment