Torn Remove RR Acts of Courage

Removes the x2 and x3 'Acts of Courage' from Russian Roulette games, and adds a 'x2' button to the RR link menu to toggle visibility

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Torn Remove RR Acts of Courage
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Removes the x2 and x3 'Acts of Courage' from Russian Roulette games, and adds a 'x2' button to the RR link menu to toggle visibility
// @author       pawl [1821105]
// @match        https://www.torn.com/page.php?sid=russianRoulette*
// @icon         https://www.google.com/s2/favicons?domain=torn.com
// @grant        GM_addStyle

// ==/UserScript==

(function() {
    'use strict';

    console.log("Torn Remove RR Acts of Courage started");

    function toggleButtonVisibility(targetButtons) {
        targetButtons.forEach(button => {
            if (button.style.display === 'none' || button.style.display === '') {
                button.style.setProperty('display', 'inline-block', 'important');
            } else {
                button.style.setProperty('display', 'none', 'important');
            }
        });
    }

    window.addEventListener('load', () => {
        const container = document.querySelector('.linksContainer___LiOTN');

        if (!container) return;

        const toggleButton = document.createElement('button');
        toggleButton.textContent = 'x2';

        toggleButton.style.fontWeight = '700';
        toggleButton.style.fontSize = '12px';
        toggleButton.style.color = 'var(--appheader-links-color)';
        toggleButton.style.textShadow = 'var(--appheader-links-text-shadow-color)';

        container.insertBefore(toggleButton, container.firstChild);

        GM_addStyle(`
            button[data-id='2'],
            button[data-id='3'] {
                display: none !important;
            }
        `);

        function getTargetButtons() {
            return Array.from(document.querySelectorAll('button[data-id="2"], button[data-id="3"]'));
        }

        toggleButton.addEventListener('click', () => {
            const targetButtons = getTargetButtons();
            toggleButtonVisibility(targetButtons);
        });

    });
})();