Torn Virus Timer
A Tampermonkey userscript that displays your virus coding timer in the Torn City sidebar. Shows the remaining time until your virus coding is complete, automatically updates, and integrates seamlessly with the Torn Tools sidebar.
Features
- ✅ Displays virus coding timer in the sidebar
- ✅ Auto-updates every hour
- ✅ Smart caching to reduce API calls
- ✅ Clickable error messages to edit API key
- ✅ Works with Torn Tools sidebar extension
- ✅ Clean, minimal display (time only)
[image: greasyfork.s3.us-east-2.amazonaws.com]
Installation
1. Install Tampermonkey 2. Install the Script- Visit Torn Virus Timer on Greasy Fork
- Click the "Install this script" button
- The script will be installed automatically in Tampermonkey
Alternatively, you can manually install:
- Click on the Tampermonkey icon → Dashboard
- Create a new script
- Copy the contents of
Torn Virus Timer.user.jsinto the editor - Save the script (Ctrl+S or Cmd+S)
- Ensure the script is enabled
- This script works best with the Torn Tools browser extension
- Install from your browser's extension store
Setup
Getting Your API Key- Go to Torn City Preferences → API
- Generate a Limited API key (not Public - virus data requires limited access)
- Copy your 16-character API key
- When you first load Torn City with the script installed, you'll see "Enter limited key" in the sidebar
- Click on it to open the API key popup
- Enter your 16-character limited API key
- Click "Save"
The script will immediately start fetching your virus status.
Usage
Viewing the Timer- The timer appears in the Torn Tools sidebar under "Virus:"
- Displays remaining time in format:
Xd Xh Xm(e.g., "19d 9h 10m") - Updates automatically every hour
Click on any of the following to edit your API key:
- "Enter limited key" (when no key is set)
- "No virus" (when no virus is being coded)
- "Invalid key" (when API key has permission issues)
- "API error" (when there's an API error)
- "Network error" (when there's a network issue)
The timer can show:
- Time remaining (e.g., "19d 9h 10m") - When a virus is being coded
- "No virus" - When no virus is currently being programmed
- "Enter limited key" - When no API key is configured
- "Invalid key" - When the API key doesn't have proper permissions
- "API error" - When there's an API error
- "Network error" - When there's a network connectivity issue
How It Works
- API Integration: Fetches virus data from
https://api.torn.com/v2/user/virususing the Torn API v2 - Smart Caching: Caches virus information in localStorage to reduce API calls
- Auto-refresh: Checks for updates every hour automatically
- Immediate Display: Shows cached timer immediately on page load
Technical Details
Storage Keys- API Key:
virus_api_key(in localStorage) - Virus Info:
virus_last_info(in localStorage)
- Endpoint:
/v2/user/virus - Authentication:
Authorization: ApiKey {YOUR_KEY}header - Key Type: Limited API key (required for user virus data)
- Rate Limiting: Checks every hour (3600 seconds)
Troubleshooting
Timer Shows "No virus" but you're coding a virus- Check that your API key is set correctly
- Verify your API key is a Limited key (not Public)
- Click "No virus" to edit your API key
- Your API key doesn't have permission to access virus data
- Make sure you're using a Limited API key
- Go to Torn City Preferences → API and verify your key permissions
- Make sure Torn Tools extension is installed
- Refresh the page
- Check browser console for errors (F12)
- Click on the timer display to edit the API key
- The script clears cache when the key is changed
- Make sure to save the new key correctly
Privacy
- Your API key is stored locally in your browser's localStorage
- No data is sent to any third-party servers
- All API calls go directly to Torn City's API
License
MIT License
Credits
- Based on the Torn War Timer script structure
- Uses Torn City API v2