Advertisement
MeKLiN2

Untitled

Jan 26th, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1. // ==UserScript==
  2. // @name verify
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-01-25
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://stumblechat.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=stumblechat.com
  9. // @grant none
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. class VerifyScript {
  14. constructor() {
  15. this.observeDOM();
  16. this.setupConsoleOverlay();
  17. }
  18.  
  19. clickVerifyButton = (verifyButton) => {
  20. this.logToOverlay('Attempting to click VERIFY button...');
  21. if (verifyButton) {
  22. this.logToOverlay('VERIFY button found.');
  23. // Remove any existing event listeners on the button
  24. verifyButton.removeEventListener('click', this.clickVerifyButton);
  25. // Manually create and dispatch a click event
  26. const clickEvent = new MouseEvent('click', {
  27. bubbles: true,
  28. cancelable: true,
  29. view: window
  30. });
  31. this.logToOverlay('Before dispatchEvent');
  32. verifyButton.dispatchEvent(clickEvent);
  33. this.logToOverlay('After dispatchEvent');
  34. } else {
  35. this.logToOverlay('VERIFY button not found.');
  36. }
  37. }
  38.  
  39. observeDOM = () => {
  40. this.logToOverlay('Setting up MutationObserver...');
  41. const observer = new MutationObserver((mutationsList) => {
  42. this.logToOverlay(`Mutation observed... ${mutationsList.length} mutation(s) in total.`);
  43. for (const mutation of mutationsList) {
  44. this.logToOverlay(`Mutation type: ${mutation.type}`);
  45. this.logToOverlay(`Mutation target: ${mutation.target.outerHTML}`);
  46. this.logToOverlay(`Added nodes: ${mutation.addedNodes.length}`);
  47. mutation.addedNodes.forEach((node) => {
  48. if (node instanceof HTMLElement) {
  49. this.logToOverlay(`Added node: ${node.nodeName}`);
  50. // Check if the added node is the VERIFY button
  51. if (node.id === 'interact') {
  52. // Add a slight delay to ensure modal visibility
  53. setTimeout(() => {
  54. // If so, click the button without scrolling
  55. this.clickVerifyButton(node);
  56. // Attempt other ways to click the button
  57. document.querySelector('#modal #interact').click(); // First attempt
  58. document.querySelector('#modal button#interact').click(); // Second attempt
  59. }, 500); // Adjust the delay as needed
  60. }
  61. }
  62. });
  63. this.logToOverlay(`Removed nodes: ${mutation.removedNodes.length}`);
  64. mutation.removedNodes.forEach((node) => {
  65. this.logToOverlay(`Removed node: ${node.nodeName}`);
  66. });
  67. }
  68. });
  69.  
  70. // Start observing changes in the sc-modal element
  71. this.logToOverlay('Attempting to observe sc-modal element...');
  72. const scModal = document.querySelector('#modal');
  73. if (scModal) {
  74. this.logToOverlay('sc-modal element found. Starting observation...');
  75. observer.observe(scModal, { childList: true, subtree: true });
  76. } else {
  77. this.logToOverlay('sc-modal element not found.');
  78. }
  79. }
  80.  
  81. setupConsoleOverlay = () => {
  82. const consoleOverlay = document.createElement('div');
  83. consoleOverlay.setAttribute('id', 'console-overlay');
  84. consoleOverlay.style.position = 'fixed';
  85. consoleOverlay.style.top = '10px';
  86. consoleOverlay.style.left = '10px';
  87. consoleOverlay.style.backgroundColor = 'rgba(255, 255, 255, 0.9)';
  88. consoleOverlay.style.padding = '10px';
  89. consoleOverlay.style.border = '1px solid #ccc';
  90. consoleOverlay.style.zIndex = '9999';
  91. document.body.appendChild(consoleOverlay);
  92. this.consoleOverlay = consoleOverlay;
  93. }
  94.  
  95. logToOverlay = (message) => {
  96. const logEntry = document.createElement('div');
  97. logEntry.textContent = message;
  98. if (this.consoleOverlay) {
  99. this.consoleOverlay.appendChild(logEntry);
  100. }
  101. console.log(message);
  102. }
  103. }
  104.  
  105. // Start the script
  106. new VerifyScript();
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement