76e3ba2488ed840641ac34f9a049a336e6542635
Mirrors the three src/ changes into the embedded copy in
torn-attribute-tracker.user.js:
1. Hoist the four let bindings (lastSnapshot, lastAttr, lastDelta,
anchorError) to the top of start(), before dialog.mount() and
applyMode(), so the anchor-miss branch of applyMode() can write
anchorError without tripping the TDZ.
2. Default the floating dialog to bottom-left (left: 20px, bottom: 20px)
in both Dialog.mount() and Dialog.setMode()'s 'free' branch.
3. One-time migration: if prefs.pos has any non-zero coordinate on load
(a residue of the bottom-right era), reset it to {x: 0, y: 0} and log
to the console. Stored position from any subsequent drag is preserved.
4. Wrap the start() body in try/catch and log failures to the console,
so an unexpected error (e.g. TornTools conflict, future regressions)
does not prevent the dialog from appearing.
All four changes are byte-equivalent to the corresponding src/ changes;
the build-time drift tests in tests/build.test.js still pass.
Torn Attribute Training Tracker
A userscript for torn.com that shows a floating dialog on the gym page with your current attribute, target, rate of gain, and an ETA to the target.
Install
- Install Tampermonkey (or Violentmonkey / Greasemonkey).
- Open
torn-attribute-tracker.user.jsin your editor, copy its contents. - In Tampermonkey, click the dashboard → + (Create new script) → paste → save.
- Visit
https://www.torn.com/gym.php. The dialog appears in the bottom-right.
Use
- Type a target value in the Target field, or pick a milestone from the dropdown.
- The dialog updates live as you train.
- Drag the header to reposition. Click Above training UI to anchor above the gym form. Click Float free to drag again.
- The ✕ closes the dialog for the current page session; it returns on next visit.
Targets, dialog position, and the 30-day train history are stored in localStorage.
Self-test
Load the script with #tat-test in the URL:
https://www.torn.com/gym.php#tat-test
Open the browser console; you'll see [tat] self-test results: followed by OK … / FAIL … lines.
Tests
npm install # no deps; node:test ships with Node 18+
npm test
Files
torn-attribute-tracker.user.js— the script you install in Tampermonkey.src/pure.js,src/store.js,src/dom.js,src/interceptor.js,src/ui.js,src/main.js— source split for testability; the user-facing file is the bundle in step 11.tests/— Node test runner (node --test).
Notes
The DOM scraper and request interceptor are best-effort matches for the current Torn gym page. If Torn updates the markup, you may need to adjust the selectors in src/dom.js and re-bundle by copying the new source into the embedded section in torn-attribute-tracker.user.js.
Description
Languages
JavaScript
100%