Skip to content

Instantly share code, notes, and snippets.

@delasy
Last active October 7, 2024 08:34
Show Gist options
  • Save delasy/7ef35c70cafe3c565949af6784a5b291 to your computer and use it in GitHub Desktop.
Save delasy/7ef35c70cafe3c565949af6784a5b291 to your computer and use it in GitHub Desktop.
Script that randomly applies promo codes for HamsterKombat
// 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',
});
});
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',
});
@delasy
Copy link
Author

delasy commented Aug 23, 2024

Okay, Thank you for all of this! It's really great what you are doing.

sure np

@mevinu-adheesha
Copy link

Can you tell me how to extract the auth token and all this stuff? What should I modify in the code? Please Guide.

@benyamin-7
Copy link

I got the point of using delay for the security and I updated my code to do that. can you take a look at it? it is a python version for collecting the coins almost every 3 hours.

https://gist.github.com/benyamin-7/4f6926b4903c30a69ec649796c0dbf71

@mevinu-adheesha
Copy link

what does this do?

it syncs your Hamster account and collects coins instead of you every 3 hours. use it only if you know how to extract auth token from Hamster and you know all the risks (no one knows if Hamster tracks this, but your account could get suspended). I used similar script for 3 months now and my account fully functional.

how to extract the auth token

@benyamin-7
Copy link

what does this do?

it syncs your Hamster account and collects coins instead of you every 3 hours. use it only if you know how to extract auth token from Hamster and you know all the risks (no one knows if Hamster tracks this, but your account could get suspended). I used similar script for 3 months now and my account fully functional.

how to extract the auth token

I actually know two methods. The first method is done directly through the mobile phone (Android), and the second method is through the telegram website. For the first method, you need to access the Hamster bot. As soon as you press the start button, disconnect your internet connection, and you'll encounter an error that the hamster's URL appears within it. Next, you should copy it, decode the URL, and then extract the auth part. In the second method, you can log into the telegram web, go to the hamster bot, start the hamster app (you'll see an error that says open the app within your mobile phone), open the chrome inspect, go to the storage session, find a key-value pair including weba, change it to android or ios, reload the hamster app within the bot by the three dots on top. Next, go to the elements, search for <iframe>, copy the hamster URL. Now, you should decode the URL and extract the auth part.

@mevinu-adheesha
Copy link

what does this do?

it syncs your Hamster account and collects coins instead of you every 3 hours. use it only if you know how to extract auth token from Hamster and you know all the risks (no one knows if Hamster tracks this, but your account could get suspended). I used similar script for 3 months now and my account fully functional.

how to extract the auth token

I actually know two methods. The first method is done directly through the mobile phone (Android), and the second method is through the telegram website. For the first method, you need to access the Hamster bot. As soon as you press the start button, disconnect your internet connection, and you'll encounter an error that the hamster's URL appears within it. Next, you should copy it, decode the URL, and then extract the auth part. In the second method, you can log into the telegram web, go to the hamster bot, start the hamster app (you'll see an error that says open the app within your mobile phone), open the chrome inspect, go to the storage session, find a key-value pair including weba, change it to android or ios, reload the hamster app within the bot by the three dots on top. Next, go to the elements, search for <iframe>, copy the hamster URL. Now, you should decode the URL and extract the auth part.

how to decode it

@benyamin-7
Copy link

benyamin-7 commented Aug 29, 2024

what does this do?

it syncs your Hamster account and collects coins instead of you every 3 hours. use it only if you know how to extract auth token from Hamster and you know all the risks (no one knows if Hamster tracks this, but your account could get suspended). I used similar script for 3 months now and my account fully functional.

how to extract the auth token

I actually know two methods. The first method is done directly through the mobile phone (Android), and the second method is through the telegram website. For the first method, you need to access the Hamster bot. As soon as you press the start button, disconnect your internet connection, and you'll encounter an error that the hamster's URL appears within it. Next, you should copy it, decode the URL, and then extract the auth part. In the second method, you can log into the telegram web, go to the hamster bot, start the hamster app (you'll see an error that says open the app within your mobile phone), open the chrome inspect, go to the storage session, find a key-value pair including weba, change it to android or ios, reload the hamster app within the bot by the three dots on top. Next, go to the elements, search for <iframe>, copy the hamster URL. Now, you should decode the URL and extract the auth part.

how to decode it

you can use the online website URL decoder such as https://www.urldecoder.org/. keep in mind you need to decode the json part of the URL twice to be fully human readable. Or you can give it to the chat gpt and ask it to decode the URL to be human readable.

@mevinu-adheesha
Copy link

what does this do?

it syncs your Hamster account and collects coins instead of you every 3 hours. use it only if you know how to extract auth token from Hamster and you know all the risks (no one knows if Hamster tracks this, but your account could get suspended). I used similar script for 3 months now and my account fully functional.

how to extract the auth token

I actually know two methods. The first method is done directly through the mobile phone (Android), and the second method is through the telegram website. For the first method, you need to access the Hamster bot. As soon as you press the start button, disconnect your internet connection, and you'll encounter an error that the hamster's URL appears within it. Next, you should copy it, decode the URL, and then extract the auth part. In the second method, you can log into the telegram web, go to the hamster bot, start the hamster app (you'll see an error that says open the app within your mobile phone), open the chrome inspect, go to the storage session, find a key-value pair including weba, change it to android or ios, reload the hamster app within the bot by the three dots on top. Next, go to the elements, search for <iframe>, copy the hamster URL. Now, you should decode the URL and extract the auth part.

how to decode it

you can use the online website URL decoder such as https://www.urldecoder.org/. keep in mind you need to decode the json part of the URL twice to be fully human readable. Or you can give it the chat gpt and ask it to decode the URL to be human readable.

okay thanks I got the parameters as 'query_id' , user and first name. Now what

@benyamin-7
Copy link

what does this do?

it syncs your Hamster account and collects coins instead of you every 3 hours. use it only if you know how to extract auth token from Hamster and you know all the risks (no one knows if Hamster tracks this, but your account could get suspended). I used similar script for 3 months now and my account fully functional.

how to extract the auth token

I actually know two methods. The first method is done directly through the mobile phone (Android), and the second method is through the telegram website. For the first method, you need to access the Hamster bot. As soon as you press the start button, disconnect your internet connection, and you'll encounter an error that the hamster's URL appears within it. Next, you should copy it, decode the URL, and then extract the auth part. In the second method, you can log into the telegram web, go to the hamster bot, start the hamster app (you'll see an error that says open the app within your mobile phone), open the chrome inspect, go to the storage session, find a key-value pair including weba, change it to android or ios, reload the hamster app within the bot by the three dots on top. Next, go to the elements, search for <iframe>, copy the hamster URL. Now, you should decode the URL and extract the auth part.

how to decode it

you can use the online website URL decoder such as https://www.urldecoder.org/. keep in mind you need to decode the json part of the URL twice to be fully human readable. Or you can give it the chat gpt and ask it to decode the URL to be human readable.

okay thanks I got the parameters as 'query_id' , user and first name. Now what

Ahh, I forgot to mention a part. Actually, the auth token there's not within the decoded URL. In fact, there's no need to decode the URL. You only need to click on the extracted URL, open your hamster kombat by a browser, then go to the inspect, check an API call's header, extract the authorization bearer token, or you could go to the local storage, extract the auth token there.

@mevinu-adheesha
Copy link

hey @delasy should we use a proxy with the sync.js

@delasy
Copy link
Author

delasy commented Sep 3, 2024

hey @delasy should we use a proxy with the sync.js

you should, if you are using HamsterKombat with proxy. ideally your device and machine you are running sync.js on, should have same IP

@mevinu-adheesha
Copy link

hey @delasy should we use a proxy with the sync.js

you should, if you are using HamsterKombat with proxy. ideally your device and machine you are running sync.js on, should have same IP

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?

@delasy
Copy link
Author

delasy commented Sep 4, 2024

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

@mevinu-adheesha
Copy link

mevinu-adheesha commented Sep 5, 2024

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

I have this sync js you provided running on the same internet connection

@mevinu-adheesha
Copy link

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

I have this sync js you provided running on the same internet connection

@delasy ??

@delasy
Copy link
Author

delasy commented Sep 6, 2024

@delasy ??

what's your question?

@mevinu-adheesha
Copy link

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

@delasy
Copy link
Author

delasy commented Sep 9, 2024

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