Tradingview Hide Unwanted Broker List Buttons

Hide buttons except those for TradeStation, OANDA, and Paper on TradingView

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Tradingview Hide Unwanted Broker List Buttons
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Hide buttons except those for TradeStation, OANDA, and Paper on TradingView
// @author       ChatGPT
// @icon          https://www.google.com/s2/favicons?sz=64&domain=tradingview.com
// @match        https://www.tradingview.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function hideUnwantedButtons() {
        // Define the brokers you want to keep
        const brokersToKeep = ['Paper', 'TRADESTATION']

        // Get all elements with the data-broker attribute
        const buttons = document.querySelectorAll('[data-broker]');

        // Loop through all buttons and hide the ones not in the brokersToKeep list
        buttons.forEach(button => {
            const broker = button.getAttribute('data-broker');
            if (!brokersToKeep.includes(broker)) {
                button.style.display = 'none';
            }
        });
    }

    // Run the function when the page loads
    window.addEventListener('load', hideUnwantedButtons);

    // Optionally, run the function again when there are changes in the DOM
    const observer = new MutationObserver(hideUnwantedButtons);
    observer.observe(document.body, { childList: true, subtree: true });

    // Adding a slight delay to ensure all elements are loaded
    setTimeout(hideUnwantedButtons, 2000);
})();