Doobie's Button Bypass

Enables attack button when user is in hospital on profile page and mini attack buttons (when holding left click on username) Mail me if you have issues

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Doobie's Button Bypass
// @namespace    http://tampermonkey.net/DoobiesButtonBypass
// @version      2.1
// @description  Enables attack button when user is in hospital on profile page and mini attack buttons (when holding left click on username) Mail me if you have issues
// @match        https://www.torn.com/profiles.php*
// @match        https://www.torn.com/factions.php*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function updateAttackButton(button) {
        if (button && button.classList.contains('disabled')) {
            button.classList.remove('disabled');
            button.classList.add('active');
            button.style.pointerEvents = 'auto';
            button.style.opacity = '1';
            button.setAttribute('aria-label', 'Attack (Bypass Hospital Restriction)');

            if (window.location.href.includes('profiles.php')) {
                let svgIcon = button.querySelector('svg');
                if (svgIcon) {
                    svgIcon.style.filter = 'none';
                    svgIcon.style.fill = '#cf3b13';
                }
            }

            if (button.querySelector('svg')) {
                let svgIcon = button.querySelector('svg');
                if (svgIcon) {
                    svgIcon.style.filter = 'none';
                    svgIcon.style.fill = '#cf3b13';
                }
            }

            button.addEventListener('click', function(e) {
                e.preventDefault();
                window.location.href = button.getAttribute('href');
            });
        }
    }

    function enableProfileAttackButtons() {
        const profileAttackButton = document.querySelector('.profile-button-attack.disabled');
        if (profileAttackButton) updateAttackButton(profileAttackButton);

        const miniAttackButtons = document.querySelectorAll('a.profile-button-attack.disabled');
        miniAttackButtons.forEach(button => updateAttackButton(button));
    }

    function enableFactionWarAttackButtons() {
        const miniAttackButtonsOnWar = document.querySelectorAll('a.profile-button-attack.disabled');
        miniAttackButtonsOnWar.forEach(button => updateAttackButton(button));
    }

    function initializeObserver() {
        const observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                    mutation.addedNodes.forEach(function(node) {
                        if (node.nodeType === 1) {
                            if (window.location.href.includes('profiles.php')) {
                                enableProfileAttackButtons();
                            } else if (window.location.href.includes('factions.php')) {
                                enableFactionWarAttackButtons();
                            }
                        }
                    });
                }
            });
        });
        observer.observe(document.body, { childList: true, subtree: true });
    }

    window.onload = function() {
        if (window.location.href.includes('profiles.php')) {
            enableProfileAttackButtons();
        } else if (window.location.href.includes('factions.php')) {
            enableFactionWarAttackButtons();
        }
        initializeObserver();
    };

})();

// Made with Love by DoobieSuckin [3255641]