Automatically optimize your company stock orders in Torn City with a single click.
This Tampermonkey userscript analyzes your company's current inventory and sales data to calculate the optimal order quantities for all items. It uses a smart algorithm to:
- Balance stock levels across all items
- Maximize warehouse space utilization
- Prioritize items based on sales velocity
- Account for items already on order
The result: efficient inventory management that keeps your shelves stocked without wasting warehouse capacity.
- A userscript manager - Install one of these browser extensions:
- Tampermonkey (Chrome, Firefox, Safari, Edge, Opera)
- Violentmonkey (Chrome, Firefox, Edge)
- Greasemonkey (Firefox only)
Option 1: Direct Install
- Click on
stock-optimizer.user.jsin this repository - Click the "Raw" button
- Your userscript manager should prompt you to install it
Option 2: Manual Install
- Copy the contents of
stock-optimizer.user.js - Open your userscript manager dashboard
- Create a new script
- Paste the code and save
- Navigate to your company management page:
https://www.torn.com/companies.php - Go to the stock ordering section (where you normally place orders)
- Look for the purple "OPTIMIZE" button next to the "PLACE ORDER" button
- Click "OPTIMIZE" to automatically calculate and fill in optimal order quantities
- Review the suggested orders (check your browser console for detailed breakdown)
- Click "PLACE ORDER" to submit the orders to Torn
Open your browser's developer console (F12) to see detailed information:
📦 Warehouse capacity: 500,000
✅ Scraped data for 12 items
=== Stock Optimization Results ===
📊 Current Stock Metrics:
Feathery Hotel Bed: 450 stock, 150 sold, 3.0 days
Ergonomic Keyboard: 800 stock, 200 sold, 4.0 days
...
📦 Warehouse: 125,000/500,000 (375,000 free)
✅ Recommended Orders:
Feathery Hotel Bed: 5,250 units
Ergonomic Keyboard: 3,200 units
...
✅ Populated 12 order fields
The optimizer uses a binary search algorithm to find the maximum "days of stock" target that fits within your available warehouse space. It:
-
Scrapes your current data from the page:
- Items in stock
- Items on order (not yet delivered)
- Daily sales per item
- Warehouse capacity
-
Calculates optimal target using binary search:
- Tries to equalize stock levels across all items (measured in days)
- Respects warehouse capacity constraints
- Skips items with zero sales
-
Distributes remaining space to highest-selling items if any capacity is left
-
Auto-fills the order forms with calculated quantities
- ✅ Zero configuration - Works out of the box
- ✅ Automatic warehouse detection - Reads your actual capacity from the page
- ✅ Accounts for pending orders - Includes items already on order in calculations
- ✅ Smart prioritization - Focuses on fast-moving inventory
- ✅ Visual feedback - Button states show processing, success, and errors
- ✅ Detailed logging - Console output explains all decisions
- ✅ AJAX-aware - Works with Torn's dynamic page updates
- Tested on: Chrome, Firefox
- Torn pages: Works on
https://www.torn.com/companies.php - Requires: Active company membership with stock ordering permissions
Button doesn't appear:
- Make sure you're on the company stock ordering page
- Wait a few seconds for Torn's AJAX to load
- Check that your userscript manager is enabled
- Verify the script is installed and active
"No items found" error:
- Ensure you're on the correct page (stock ordering section)
- Check that your company has items to order
- Verify the page has fully loaded
Orders seem incorrect:
- Check console output for detailed calculations
- Verify your warehouse capacity is detected correctly
- Ensure sales data is up-to-date on the page
Warehouse capacity wrong:
- Script reads capacity from page - if not found, defaults to 500,000
- Check console for "Warehouse capacity" message
- If incorrect, report as a bug
See CLAUDE.md for technical documentation and development guidelines.
MIT License - See LICENSE file for details.
This is a client-side automation tool that reads and interacts with Torn's web interface. It does not:
- Access Torn's API
- Modify game data directly
- Violate Torn's terms of service (it's equivalent to manual form filling)
Use at your own discretion. The author is not responsible for any issues arising from use of this script.
Contributions welcome! Please:
- Test changes thoroughly on actual Torn pages
- Maintain existing code style
- Update CLAUDE.md if changing architecture
- Verify button injection works with AJAX navigation
If you encounter issues:
- Check the browser console for error messages
- Verify Torn's page structure hasn't changed
- Open an issue in this repository with:
- Browser and userscript manager versions
- Console error messages
- Steps to reproduce
Made for the Torn community 🎯