Tradingview Hide Unwanted Broker List Buttons

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

  1. // ==UserScript==
  2. // @name Tradingview Hide Unwanted Broker List Buttons
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description Hide buttons except those for TradeStation, OANDA, and Paper on TradingView
  6. // @author ChatGPT
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=tradingview.com
  8. // @match https://www.tradingview.com/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function hideUnwantedButtons() {
  17. // Define the brokers you want to keep
  18. const brokersToKeep = ['Paper', 'TRADESTATION']
  19.  
  20. // Get all elements with the data-broker attribute
  21. const buttons = document.querySelectorAll('[data-broker]');
  22.  
  23. // Loop through all buttons and hide the ones not in the brokersToKeep list
  24. buttons.forEach(button => {
  25. const broker = button.getAttribute('data-broker');
  26. if (!brokersToKeep.includes(broker)) {
  27. button.style.display = 'none';
  28. }
  29. });
  30. }
  31.  
  32. // Run the function when the page loads
  33. window.addEventListener('load', hideUnwantedButtons);
  34.  
  35. // Optionally, run the function again when there are changes in the DOM
  36. const observer = new MutationObserver(hideUnwantedButtons);
  37. observer.observe(document.body, { childList: true, subtree: true });
  38.  
  39. // Adding a slight delay to ensure all elements are loaded
  40. setTimeout(hideUnwantedButtons, 2000);
  41. })();