dullson / TradingView remove "go pro" popups

// ==UserScript==
// @name        TradingView remove "go pro" popups
// @description Silently removes "go pro" popups without displaying
// @author      dullson
// @match       https://www.tradingview.com/chart/*
// @grant       none
// @version     1.0
// @copyright 2021, dullson (https://openuserjs.org/users/dullson)
// @license MIT

// ==/UserScript==

const popupQueries = ['[data-dialog-name="gopro"]', '[class*="toast-positioning-wrapper"]'];

const callback = function (mutationsList, observer) {
  for (const mutation of mutationsList) {
    for (const addedNode of mutation.addedNodes) {
      if (!addedNode.tagName) continue; // not element
      if (popupQueries.some(x => addedNode.matches(x))) {
        console.log("found matching popup, clicking x", addedNode);
        addedNode.querySelector('button').click();
      }
    }
  }
}

const observer = new MutationObserver(callback);
observer.observe(document.body, {
  childList: true,
  subtree: true
});