Skip to content
TORNLIFE More

[SCRIPT] Torn Virus Coding Timer

Started by Woeka [3516612] on in Tools & Userscripts.

4 replies · 290 views · thread synced · 5 days ago · View on torn.com
About this thread

Posts archived: 5 / 5 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
5
Discussion span
→
People posting
4
Likes on archived posts
13
Authority score
36 / 100
Historical score
27 / 100
Story score
37 / 100
Engagement score
59 / 100
Woeka [3516612]

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

Alternatively, you can manually install:

  • Click on the Tampermonkey icon → Dashboard
  • Create a new script
  • Copy the contents of Torn Virus Timer.user.js into the editor
  • Save the script (Ctrl+S or Cmd+S)
  • Ensure the script is enabled
3. Install Torn Tools (Optional but recommended)
  • This script works best with the Torn Tools browser extension
  • Install from your browser's extension store

Setup

Getting Your API Key
  1. Go to Torn City Preferences → API
  2. Generate a Limited API key (not Public - virus data requires limited access)
  3. Copy your 16-character API key
Configuring the Script
  1. When you first load Torn City with the script installed, you'll see "Enter limited key" in the sidebar
  2. Click on it to open the API key popup
  3. Enter your 16-character limited API key
  4. 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
Editing API Key

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)
States

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

  1. API Integration: Fetches virus data from https://api.torn.com/v2/user/virus using the Torn API v2
  2. Smart Caching: Caches virus information in localStorage to reduce API calls
  3. Auto-refresh: Checks for updates every hour automatically
  4. 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)
API Requirements
  • 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
Timer Shows "Invalid 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
Timer Not Appearing
  • Make sure Torn Tools extension is installed
  • Refresh the page
  • Check browser console for errors (F12)
Wrong API Key Being Used
  • 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
Caio [2488372]

Did not saw the prompt requesting the API key once installed nor at any page after it... bit afraid of breaking the capture of it on the code; is there any line on it where I could replace with the key for it to work?

Edit: NVM seems it is on the left bar already to click to pop up and insert the key; very smart but we are not usually ready to input this way hence the confusion

Cascade__ [3945447]

An excellent and very useful script, thank you Woeka.

I felt the hourly API call was a lot, I changed mine to daily, until last 6 hours, then hourly.  Subjective opinion.   :)