Auto Click OK Button For Broker Warning

Automatically clicks the "Ok" button in specified dialog

当前为 2024-05-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Auto Click OK Button For Broker Warning
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Automatically clicks the "Ok" button in specified dialog
  6. // @author ChatGPT lel
  7. // @match https://www.tradingview.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to click the "Ok" button
  15. function clickOkButton() {
  16. const okButton = document.querySelector('.dialog-qyCw0PaN button[name="yes"]');
  17. if (okButton) {
  18. okButton.click();
  19. }
  20. }
  21.  
  22. // Observe changes in the document to detect the appearance of the dialog
  23. const observer = new MutationObserver((mutationsList, observer) => {
  24. for(const mutation of mutationsList) {
  25. if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
  26. clickOkButton();
  27. }
  28. }
  29. });
  30.  
  31. // Start observing the document for changes
  32. observer.observe(document.body, { childList: true, subtree: true });
  33.  
  34. })();