Skip to content

Instantly share code, notes, and snippets.

@papalardo
Last active September 13, 2022 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papalardo/652d0f8ff630bf647a7b99835158ab30 to your computer and use it in GitHub Desktop.
Save papalardo/652d0f8ff630bf647a7b99835158ab30 to your computer and use it in GitHub Desktop.
MonsterQuest BOT
// https://play.monsterquest.io/
// Usage:
// Copy this content, create file with `index.js` name
// Copy access token at browser sessionStorage and replace `accessToken` var (line 13) with it
// Run on terminal:
// npm i axios
// node index.js
const axios = require("axios");
const accessToken = "";
const baseURL = "https://apiv1.monsterquest.io";
const http = axios.create({
baseURL,
headers: {
authorization: `Bearer ${accessToken}`,
contentType: "application/json",
accept: "application/json"
},
});
http.interceptors.response.use(function (response) {
return response.data;
});
const getUserMonsters = () => http.get("/api/monsters/userPaginate")
.then(({ data }) => data);
// Is mandatory get enemies before battle, maybe to create session
const getMonsterEnemies = (monster) => http.get(`/api/battle/${monster.id}`)
const battle = (monster, enemyPosition = 1) => {
return http.post('/api/battle/', {
"monsterId": monster.id,
"enemy": enemyPosition,
"skill": false
});
}
const delay = (time = 3000) => new Promise((resolve) => setTimeout(resolve, time));
const main = async () => {
const userMonsters = await getUserMonsters();
for(let monsterIndex in userMonsters) {
const monster = userMonsters[monsterIndex];
const monsterBattleCount = Math.floor(monster.energy / 10);
for(let i = 0; i < monsterBattleCount; i++) {
await getMonsterEnemies(monster);
const battleResult = await battle(monster);
console.log(`
Battle Result
${battleResult.battleStatus ? 'WIN' : 'LOSE'}
Rewards: ${battleResult.rewards}
Orbs: ${battleResult.orbs}
Drops: ${battleResult.drop.length}
=================================================`
)
await delay();
}
}
}
void main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment