$ show Nuklon/Steam-Economy-Enhancer
Steam Economy Enhancer is a single-file userscript (~4,500 lines) that runs via Violentmonkey on Steam Community pages. It detects whether the current URL is an inventory, market, market-listing, or trade-offer page and initializes a matching enhancement module. On the inventory it injects bulk-sell/card-sell/crate-sell buttons, duplicate detection, gem conversion, booster pack unpacking, per-item price labels, and quick-sell panels populated from Steam's order book. On the market it identifies overpriced/underpriced listings against a price heuristic, supports mass removal and auto-relisting, adds client-side search/sort/select-all controls, and aggregates total listing values. On trade offers it renders per-party item counts and price summaries. All server actions are executed through Steam's internal AJAX endpoints using the user's own session cookie. Under the hood, the script is organized as an IIFE with region annotations. Every external call flows through a hand-built serialized request queue with adaptive rate limiting (300ms baseline, 1s for market endpoints, 5s after errors) and a circuit breaker that halts after repeated HTTP 400/401/403/404/405/429 responses. Long-running operations (selling, relisting, grinding, pricing) are run through async.queue pipelines with concurrency 1, jittered delays, and 30-45s backoff retries. A rolling session cache built on localforage keeps price histories and order books across tab restarts while rotating through six bounded IndexedDB buckets to prevent unbounded growth. The fee engine precisely mirrors Steam's market fee math, including the December 2025 rule changes for 11 currencies that switched from floor to round and introduced a $0.01 minimum per fee. The code is heavily coupled to Steam's page globals (g_rgAssets, g_ActiveInventory, g_rgWalletInfo) and DOM structure, so the script cannot run outside steamcommunity.com. However, several embedded patterns are self-contained and instructive: the request queue, the rolling session cache, the fee calculation engine, and the pure-function price heuristic. Maintenance is healthy: the code incorporates December 2025 Steam rule changes, uses modern library versions, and CI runs ESLint on every push. There are no unit testsβthe only automated check is linting.
The LLM identified 3 files worth highlighting for reuse:
The `request()` function is a hand-rolled serialized AJAX client that queues all calls while one is in flight, applies endpoint-aware throttling (300ms default, 1s for /market/ calls, 5s after failures), and implements a circuit breaker: five HTTP statuses in [400, 401, 403, 404, 405, 429] within a five-minute window halts outbound requests to avoid triggering Steam rate-limit bans. Errors are converted into structured Error objects with URL/method/status/responseText, and callbacks are always deferred via setTimeout so the queue cannot deadlock. It is a self-contained pattern (~80 lines) that transfers directly to any API client needing polite rate limiting once $.ajax is swapped for fetch.
`CalculateAmountToSendForDesiredReceivedAmount` and `CalculateFeeAmount` faithfully reimplement Steam's market fee mathematics from the walletInfo structure. They handle percent + base fees, per-publisher fee overrides, an iterative loop correcting cent-level rounding drift when converting buyer price to seller price, and the December 2025 Steam rule changes: 11 currencies (JPY, KRW, VND, etc.) now round fees instead of flooring them, and both Steam and publisher fees have a $0.01 local-currency minimum. This is a definitive reference implementation for any Steam economy tool and is directly liftable.
A session cache that survives restarts without growing unbounded: the code maintains six IndexedDB buckets (see_session_0..5), advances to the next bucket each browser session using a sessionStorage sentinel, clears the bucket it is about to enter, and wraps it with the localforage API. Price histories and order books cached in the current bucket live across tab closes (unlike sessionStorage) but storage is automatically reclaimed after at most six sessions. This is an elegant, fully generic caching pattern that can be extracted to any app needing short-lived but restart-durable caching.