Torn Attack Button Enabler (Force Link)

Enables the attack button on mini profiles and profile pages

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 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();
})();