Torn - Disable Booster Tab

Makes the Booster tab appear and behave as disabled on the item page.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Torn - Disable Booster Tab
// @namespace    gin4
// @version      1.1
// @description  Makes the Booster tab appear and behave as disabled on the item page.
// @match        https://www.torn.com/item.php*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const disableBoosterTab = (tab) => {
        if (!tab || tab.classList.contains('ui-state-disabled')) return;

        // Add Torn's disabled classes
        tab.classList.add('ui-state-disabled', 'no-items');
        tab.setAttribute('aria-disabled', 'true');
        tab.setAttribute('aria-selected', 'false');
        tab.setAttribute('tabindex', '-1');

        // Remove active/selected state if present
        tab.classList.remove('ui-tabs-active', 'ui-state-active');
        tab.removeAttribute('aria-controls');

        // Disable its link
        const link = tab.querySelector('a');
        if (link) {
            link.removeAttribute('href');
            link.removeAttribute('tabindex');
            link.style.pointerEvents = 'none';
            link.title = 'Disabled';
        }
    };

    // Observe the DOM since Torn loads tabs dynamically
    const observer = new MutationObserver(() => {
        const boosterTab = document.querySelector('li#categoriesItem[data-type="Booster"]');
        if (boosterTab) {
            disableBoosterTab(boosterTab);
            observer.disconnect();
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();