Torn Attack Button Enabler (Force Link)

Enables the attack button on mini profiles and profile pages

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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();
})();