Last active
October 7, 2024 08:34
-
-
Save delasy/7ef35c70cafe3c565949af6784a5b291 to your computer and use it in GitHub Desktop.
Script that randomly applies promo codes for HamsterKombat
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
// insert hamster-kombat-playground-games-promo-keys-generator.js here | |
// with removed `async function main() {...}` and `main().catch(Logger.panic);` | |
const { CronJob } = require('cron'); | |
const HK_TOKEN = '<api-token>'; | |
async function applyPromo(promoCode) { | |
await fetch('https://api.hamsterkombatgame.io/clicker/apply-promo', { | |
method: 'POST', | |
headers: { | |
Authorization: `Bearer ${HK_TOKEN}`, | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ promoCode }), | |
}); | |
} | |
async function applyPromoCron(gameKey) { | |
const gp = new GamePromo(); | |
for (let j = 0; j < 4; j++) { | |
const promoCode = await gp.getCode(gameKey); | |
await applyPromo(promoCode); | |
} | |
} | |
const jobs = [ | |
{ | |
schedule: '0 42 10 * * *', | |
command: async () => applyPromoCron('BIKE'), | |
}, | |
{ | |
schedule: '0 15 12 * * *', | |
command: async () => applyPromoCron('TRAIN'), | |
}, | |
{ | |
schedule: '0 31 14 * * *', | |
command: async () => applyPromoCron('CUBE'), | |
}, | |
{ | |
schedule: '0 21 16 * * *', | |
command: async () => applyPromoCron('CLONE'), | |
}, | |
{ | |
schedule: '0 36 18 * * *', | |
command: async () => applyPromoCron('MERGE'), | |
}, | |
{ | |
schedule: '0 12 20 * * *', | |
command: async () => applyPromoCron('TWERK'), | |
}, | |
{ | |
schedule: '0 21 22 * * *', | |
command: async () => applyPromoCron('POLY'), | |
}, | |
]; | |
jobs.forEach((job) => { | |
CronJob.from({ | |
cronTime: job.schedule, | |
onTick: job.command, | |
start: true, | |
timeZone: 'utc', | |
}); | |
}); |
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
const { CronJob } = require('cron'); | |
const HK_TOKEN = '<api-token>'; | |
function sync() { | |
const randomMinute = Math.floor(Math.random() * 60); | |
setTimeout(() => { | |
fetch('https://api.hamsterkombatgame.io/clicker/sync', { | |
method: 'POST', | |
headers: { | |
Authorization: `Bearer ${HK_TOKEN}`, | |
'Content-Type': 'application/json', | |
} | |
}); | |
}, randomMinute * 60_000); | |
} | |
CronJob.from({ | |
cronTime: '0 0 */2 * * *', | |
onTick: sync, | |
start: true, | |
timeZone: 'utc', | |
}); |
Isn't it the same IP when I run Hamster Kombat on a machine and a device (phone) that are connected to the same Wi-Fi?
should be same IP, not sure what configuration you have
what do you mean by configuration? I have this sync js you provided running on the same internet connection
what do you mean by configuration? I have this sync js you provided running on the same internet connection
then you should be good
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what's your question?