473 checkboxes, 3 KB of JavaScript, no account: how a camo tracker stores progress
The data set first, because the rest follows from it. Modern Warfare 4 ships 33 weapons, each with 14 camo challenge rows (8 Military, 3 Special, then Gold, Platinum, Harmonic Break), plus an 11-row Mastery ladder that belongs to the account rather than to any one gun. 33 × 14 + 11 = 473 rows.
That is the whole of the tracker at mw4camotracker.com: 473 checkboxes spread across 33 weapon pages, a CSV with the same 473 rows under CC BY 4.0, and a client file that is 3,146 bytes minified. No framework, no bundler on the client, no login.
The saved state is smaller than the data set
Progress lives in one localStorage key, mw4ct:v1. The value is a sparse map: a row appears in it only after you tick it.
if (b.checked) s[b.dataset.c] = 1; else delete s[b.dataset.c];
Clearing a box deletes the key instead of writing a zero. The payload therefore grows with what you have finished, not with what the tool knows. A completely finished tracker with all 473 rows ticked measures 8,391 bytes as JSON — and that is the worst case. Someone who has done nothing stores {}.
Compare that with shipping the dataset to the browser: the build input for the pages is a 41,807-byte JSON file. The state is roughly a fifth of it, and only at 100%.
Counters are computed, then deliberately clipped
There is no goldCount field to keep in sync. The script walks the map on every change and counts keys by suffix:
function countProgress(o){var c={g:0,p:0,h:0,d:0};for(var k in o){if(!o[k])continue;
if(k==='mastery.0')c.d=1;
if(/\.gold$/.test(k))c.g++; if(/\.plat$/.test(k))c.p++; if(/\.hb$/.test(k))c.h++}
c.g=Math.min(33,c.g); c.p=Math.min(33,c.p); c.h=Math.min(33,c.h); c.d=Math.min(1,c.d); return c}
Two things are worth copying here. The counters cannot drift, because nothing writes them. And the Math.min calls are an admission: state parsed from storage can be wrong. A duplicated key, a hand-edited value, a stale migration — any of those could produce "34/33 gold", so the display clamps instead of trusting the count. The clamp hides the underlying corruption, but it keeps the page honest about the range, and the visible number is the one people screenshot.
The suffix convention (.gold, .plat, .hb, mastery.0) is doing more work than a schema would. It is also the weak point: rename a camo row and old progress silently stops counting. On a data set that changes with patches, a version field in the key (mw4ct:v1) is the only migration handle, and there is exactly one.
The share link carries four integers, not your checklist
Clicking share builds a URL from the counted totals:
function encodeProgress(c){return b64uEncode(JSON.stringify({v:1,g:c.g|0,p:c.p|0,h:c.h|0,d:c.d|0}))}
That JSON is 32 bytes; base64url makes it 43 characters. A full share URL is 78 characters:
https://mw4camotracker.com/share?p=eyJ2IjoxLCJnIjoxMiwicCI6NywiaCI6MywiZCI6MH0
Opening it renders a card reading Gold 12/33, Platinum 7/33, Harmonic Break 3/33, Divergence 0/1, with a copy button and a PNG download. The reader gets a scoreboard, not a saved checklist — nobody else's ticks are in the URL, and there is nothing to import.
The decode side is where the interesting decisions are:
function decodeProgress(x){if(!x||String(x).length>200)return null;
try{var o=JSON.parse(b64uDecode(x)); if(!o||o.v!==1)return null;
var c={g:o.g|0,p:o.p|0,h:o.h|0,d:o.d|0};
if(c.g<0||c.g>33||c.p<0||c.p>33||c.h<0||c.h>33||c.d<0||c.d>1)return null; return c}catch(e){return null}}
Three bounds, all cheap: a 200-character cap before decoding, a version check after parsing, and a range check on every field. A share parameter is attacker-controlled input that gets rendered into a social card, so "it came from our own button" is not a reason to skip validation. Anything that fails returns null and the page falls back to a default card.
What this design gives up
No sync. Tick rows on your phone and they stay on your phone; the same holds for a second browser. The wipe button asks for one confirm and then erases everything, which is the correct amount of friction for data that lives in one place and has no server copy.
Local storage also disappears when someone clears site data, and no amount of client code prevents that. The mitigation is the CSV: all 473 rows with 18 columns — requirement text, level gate, MP and DMZ counts, the basis for each number, the source URL, and the date it was checked — downloadable and reusable. If the browser forgets your progress, the challenge list is still there to work from.
The checklist I would reuse
- Store only what the user produced. Derive everything else at read time.
- Delete keys instead of writing false values; measure the worst case, not the average.
- Clamp computed values before rendering, and treat the clamp as a bug report.
- Put a version in the storage key the day you create it.
- Encode the smallest honest payload in a share link, and validate it as hostile input.
- Publish the source data so the tool is not the only copy.
None of that needs a framework. It needs 3 KB and a decision about what not to store.
Canonical: https://mw4camotracker.com/
Top comments (1)
The CSV preserves the reference data, but not the user-generated half of the system: the 473 ticks. If recovery after site-data deletion matters, exporting and importing
mw4ct:v1would be a separate feature.That import should treat storage keys as untrusted too. Rather than counting every
.goldsuffix and clamping the result, intersect imported IDs with the current manifest and report orphaned IDs from older versions. That gives a rename such asweaponA.goldtoweaponB.goldan explicit migration path; the versioned key alone only separates buckets, it cannot map old row identities to new ones.