Torn Attack Button Enabler (Force Link)

Enables the attack button on mini profiles and profile pages

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.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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 Button Enabler (Force Link)
// @description  Enables the attack button on mini profiles and profile pages
// @version      1.5
// @author       dingus
// @match        https://www.torn.com/*
// @run-at       document-start
// @grant        none
// @namespace https://greasyfork.org/users/1571407
// ==/UserScript==

(function() {
    'use strict';

    const forceEnableButtons = () => {
        const attackButtons = document.querySelectorAll('a.profile-button-attack');

        attackButtons.forEach(btn => {
            if (btn.classList.contains('disabled')) {
                btn.classList.remove('disabled');
                btn.classList.add('active');
                btn.style.pointerEvents = 'auto';
                btn.style.cursor = 'pointer';
            }

            const svg = btn.querySelector('svg.profile-mini-_disabled___dhYPV');
            if (svg) {
                svg.classList.remove('profile-mini-_disabled___dhYPV');
                svg.style.filter = 'none';
                svg.style.opacity = '1';
            }

            if (!btn.dataset.hacked) {
                btn.dataset.hacked = "true";

                btn.addEventListener('click', function(e) {
                    e.preventDefault();
                    e.stopPropagation();

                    const targetUrl = btn.getAttribute('href');
                    if (targetUrl && targetUrl !== '#') {
                        window.location.href = targetUrl;
                    }
                }, true);
            }
        });
    };

    const observer = new MutationObserver(() => forceEnableButtons());
    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });

    setInterval(forceEnableButtons, 1000);
    forceEnableButtons();
})();