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 για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey 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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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