Torn Attack Next ID Button

Adds a button that increments the attack URL user ID and reloads the page

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Torn Attack Next ID Button
// @namespace    idrinkcereal.torn
// @version      1.0
// @description  Adds a button that increments the attack URL user ID and reloads the page
// @match        https://www.torn.com/loader.php?sid=attack*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  // Create the button
  const btn = document.createElement('button');
  btn.textContent = 'Next ID';
  btn.style.position = 'fixed';
  btn.style.top = '10px';
  btn.style.right = '10px';
  btn.style.zIndex = '9999';
  btn.style.padding = '8px 12px';
  btn.style.backgroundColor = '#222';
  btn.style.color = '#fff';
  btn.style.border = '1px solid #555';
  btn.style.borderRadius = '5px';
  btn.style.cursor = 'pointer';
  btn.style.fontSize = '14px';
  btn.style.fontFamily = 'Arial, sans-serif';
  btn.title = 'Go to the next user ID';

  // Add click action
  btn.addEventListener('click', () => {
    const url = new URL(window.location.href);
    const id = parseInt(url.searchParams.get('user2ID'));
    if (!isNaN(id)) {
      const nextId = id + 1;
      url.searchParams.set('user2ID', nextId);
      window.location.href = url.toString(); // reloads with new ID
    } else {
      alert('Could not detect a valid user2ID in the URL.');
    }
  });

  // Add to page
  document.body.appendChild(btn);
})();