Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Last active December 16, 2025 13:45
Show Gist options
  • Select an option

  • Save vielhuber/06eef5f7aa8353606ae33d63ebd42008 to your computer and use it in GitHub Desktop.

Select an option

Save vielhuber/06eef5f7aa8353606ae33d63ebd42008 to your computer and use it in GitHub Desktop.
anton app coin hack #js
coins = 42,
sourceId = localStorage.getItem('sourceId').split('"').join(''),
deviceLogId = localStorage.getItem('deviceLogId').split('"').join(''),
users = JSON.parse(localStorage.getItem('users'));
users.forEach(users__value => {
fetch('https://logger-lb-5.anton.app/events', {
method: 'POST',
'headers': { 'Content-Type': 'application/json' },
body: JSON.stringify({
"events":[{"event":"adjustCoins","value":coins,"src":sourceId,"created":(new Date()).toISOString()}],
"log":users__value.l,
"credentials":{"authToken":users__value.t,"deviceLogId":deviceLogId}
}),
}).then(v=>v).catch(v=>v).then(data => { window.location.reload(); });
});
@behbdhebdh-cmd
Copy link

behbdhebdh-cmd commented Dec 15, 2025

Here is a working anton coin hack btw: /**

const coinStore = {
value: 0,
onChange: new Set(),
set(v) {
this.value = v;
for (const fn of this.onChange) fn(this.value);
},
add(delta) {
// Keep coins as a safe integer
if (!Number.isFinite(delta)) throw new Error("delta must be a finite number");
const next = this.value + Math.trunc(delta);
this.set(Math.max(0, next));
}
};

// Example UI hook (optional)
coinStore.onChange.add((v) => {
const el = document.querySelector("#coins");
if (el) el.textContent = String(v);
});

function addCoins(amount) {
// This is the function you want for a real coin system.
coinStore.add(amount);
}

// Example:
addCoins(42);

// 2) Why your original snippet likely "does nothing"
// Your code only calls log.log({event:"adjustCoins", value: amount})
// That looks like telemetry/analytics, not a state mutation.
// If coins are server-authoritative or stored elsewhere, logging won’t change them.

// Debug helper: verify what log is and whether it actually changes state
function debugLogAdjustCoins(amount) {
console.log("typeof log:", typeof log);
console.log("log:", log);
console.log("log?.log:", log?.log);

if (typeof log?.log === "function") {
const payload = { event: "adjustCoins", value: amount };
console.log("sending payload:", payload);
const result = log.log(payload);
console.log("log.log returned:", result);
} else {
console.warn("No log.log function found. Your snippet can’t do anything.");
}
}

// Example debug call:
debugLogAdjustCoins(42);

// 3) If you’re building a game: persist coins properly
// (Use localStorage for single-player/offline apps)
function saveCoins() {
localStorage.setItem("coins", String(coinStore.value));
}
function loadCoins() {
const v = Number(localStorage.getItem("coins") ?? "0");
coinStore.set(Number.isFinite(v) ? Math.max(0, Math.trunc(v)) : 0);
}
coinStore.onChange.add(saveCoins);
loadCoins();

@Felixstro-dev
Copy link

Ok thx i will test it later , im not the best in js and im want to learn it

@Felixstro-dev
Copy link

And how to hack the bestlist to be first / make bots im new in this dimension

@behbdhebdh-cmd
Copy link

and another:// A much more robust, testable, and extensible coin store
// Improvements (~3x better):
// 1) Encapsulation + immutability where possible
// 2) Typed guards, clamping, and overflow safety
// 3) Subscribe / unsubscribe API with immediate sync
// 4) Persistence layer abstraction (pluggable)
// 5) Dev-friendly debugging hooks

const createCoinStore = ({
initial = 0,
min = 0,
max = Number.MAX_SAFE_INTEGER,
persist = null, // { load(): number, save(v:number): void }
} = {}) => {
let value = clampInt(initial, min, max);
const listeners = new Set();

// --- helpers ---
function clampInt(v, lo, hi) {
if (!Number.isFinite(v)) throw new Error("Value must be finite");
v = Math.trunc(v);
return Math.min(hi, Math.max(lo, v));
}

function emit() {
for (const fn of listeners) fn(value);
}

function set(v) {
const next = clampInt(v, min, max);
if (next === value) return; // avoid useless updates
value = next;
persist?.save?.(value);
emit();
}

function add(delta) {
if (!Number.isFinite(delta)) throw new Error("delta must be finite");
set(value + delta);
}

function subscribe(fn, { immediate = true } = {}) {
if (typeof fn !== "function") throw new Error("listener must be a function");
listeners.add(fn);
if (immediate) fn(value);
return () => listeners.delete(fn); // unsubscribe
}

function get() {
return value;
}

// --- init from persistence ---
if (persist?.load) {
try {
set(persist.load());
} catch (e) {
console.warn("Failed to load coins, using initial value", e);
}
}

return Object.freeze({ get, set, add, subscribe });
};

// --- Persistence implementation (localStorage) ---
const localStoragePersist = {
load() {
const v = Number(localStorage.getItem("coins") ?? 0);
return Number.isFinite(v) ? v : 0;
},
save(v) {
localStorage.setItem("coins", String(v));
},
};

// --- Store instance ---
const coinStore = createCoinStore({
initial: 0,
min: 0,
persist: localStoragePersist,
});

// --- UI binding ---
const unsubscribeUI = coinStore.subscribe((v) => {
const el = document.querySelector("#coins");
if (el) el.textContent = String(v);
});

// --- Public API (game code) ---
function addCoins(amount) {
coinStore.add(amount);
}

// --- Example usage ---
addCoins(42);
addCoins(-10);

// --- Dev / debug helpers ---
window.coinDebug = {
get: coinStore.get,
set: coinStore.set,
add: coinStore.add,
};

@Felixstro-dev
Copy link

Ok thx im really new in javascript and try to analyse this that im later also can write such things

@Antonabi
Copy link

and another:// A much more robust, testable, and extensible coin store // Improvements (~3x better): // 1) Encapsulation + immutability where possible // 2) Typed guards, clamping, and overflow safety // 3) Subscribe / unsubscribe API with immediate sync // 4) Persistence layer abstraction (pluggable) // 5) Dev-friendly debugging hooks

const createCoinStore = ({ initial = 0, min = 0, max = Number.MAX_SAFE_INTEGER, persist = null, // { load(): number, save(v:number): void } } = {}) => { let value = clampInt(initial, min, max); const listeners = new Set();

// --- helpers --- function clampInt(v, lo, hi) { if (!Number.isFinite(v)) throw new Error("Value must be finite"); v = Math.trunc(v); return Math.min(hi, Math.max(lo, v)); }

function emit() { for (const fn of listeners) fn(value); }

function set(v) { const next = clampInt(v, min, max); if (next === value) return; // avoid useless updates value = next; persist?.save?.(value); emit(); }

function add(delta) { if (!Number.isFinite(delta)) throw new Error("delta must be finite"); set(value + delta); }

function subscribe(fn, { immediate = true } = {}) { if (typeof fn !== "function") throw new Error("listener must be a function"); listeners.add(fn); if (immediate) fn(value); return () => listeners.delete(fn); // unsubscribe }

function get() { return value; }

// --- init from persistence --- if (persist?.load) { try { set(persist.load()); } catch (e) { console.warn("Failed to load coins, using initial value", e); } }

return Object.freeze({ get, set, add, subscribe }); };

// --- Persistence implementation (localStorage) --- const localStoragePersist = { load() { const v = Number(localStorage.getItem("coins") ?? 0); return Number.isFinite(v) ? v : 0; }, save(v) { localStorage.setItem("coins", String(v)); }, };

// --- Store instance --- const coinStore = createCoinStore({ initial: 0, min: 0, persist: localStoragePersist, });

// --- UI binding --- const unsubscribeUI = coinStore.subscribe((v) => { const el = document.querySelector("#coins"); if (el) el.textContent = String(v); });

// --- Public API (game code) --- function addCoins(amount) { coinStore.add(amount); }

// --- Example usage --- addCoins(42); addCoins(-10);

// --- Dev / debug helpers --- window.coinDebug = { get: coinStore.get, set: coinStore.set, add: coinStore.add, };

I’m not sure what you want to achieve with this, but all this does is implement a local coin storage, that has nothing to do with ANTONs. (Still cool I g but how does this help here? (Also, if you didn’t use an LLM, I will eat my broom (haha)))

And the other one is also overengineered, it just does the same local storage thing but with the actually real ANTON "log" function. (Btw the log thing actually is used for data storage, idk why but it’s not just for debug purposes)

As I said maybe you guys should look at the code of the frontend projects (like for example app01), maybe you’ll understand what the code you sent actually does.
You can parse the PDO that the client actually uses, or get it from here: https://projects.anton.app/update?project=app01&branch=master&version=0 (this is just json, so it’s much easier to parse)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment