AutoVerify

AutoVerify StumbleChat

  1. // ==UserScript==
  2. // @name AutoVerify
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description AutoVerify StumbleChat
  6. // @author MeKLiN
  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. // @license MIT
  12. // ==/UserScript==
  13.  
  14. var scripts = document.getElementsByTagName("script");
  15. var script = null;
  16. var found = false;
  17.  
  18. for (var i = 0; i < scripts.length; i++) {
  19. script = scripts[i];
  20. if (/^jQuery.*\.js$/i.test(script.src)) {
  21. found = true;
  22. break;
  23. }
  24. }
  25.  
  26. if (!found) {
  27. try {
  28. $ || jQuery || $ === jQuery;
  29. found = true;
  30. } catch (err) {
  31.  
  32. }
  33. }
  34.  
  35. if (!found) {
  36. // inject jQuery.
  37. script = document.createElement("script");
  38. script.type = "text/javascript";
  39.  
  40. var protocol = /^https:/i.test(document.location) ? "https" : "http";
  41. script.src = protocol + "://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
  42. document.getElementsByTagName("body")[0].appendChild(script);
  43. }
  44.  
  45. // Define App globally
  46. window.App = {
  47. Init: () => {
  48. // Define the behavior of App.Init() here
  49. console.log('App.Init() called');
  50. }
  51. };
  52.  
  53. class VerifyScript {
  54. constructor() {
  55. this.observeDOM();
  56. this.setupConsoleOverlay();
  57. this.clickCount = 0;
  58. }
  59.  
  60. clickVerifyButton = (verifyButton) => {
  61. this.clickCount++;
  62. this.logToOverlay(`Attempting to click VERIFY button ${this.clickCount} time(s)...`);
  63. if (verifyButton) {
  64. this.logToOverlay('VERIFY button found.');
  65. // Remove any existing event listeners on the button
  66. verifyButton.removeEventListener('click', this.clickVerifyButton);
  67. // Manually create and dispatch a click event
  68. const clickEvent = new MouseEvent('click', {
  69. bubbles: true,
  70. cancelable: true,
  71. view: window
  72. });
  73. this.logToOverlay('Before dispatchEvent');
  74. verifyButton.dispatchEvent(clickEvent);
  75. this.logToOverlay('After dispatchEvent');
  76.  
  77. if (this.clickCount < 3) {
  78. setTimeout(() => {
  79. if (this.isMouseLocked()) {
  80. this.sendMouseUp();
  81. }
  82. this.clickVerifyButton(verifyButton);
  83. }, 500); // Delay between clicks
  84. } else if (this.clickCount === 3) {
  85. // After the third click, call App.Init()
  86. this.logToOverlay('Third click completed, calling App.Init()...');
  87. setTimeout(() => {
  88. this.logToOverlay('Calling App.Init()...');
  89. App.Init();
  90. }, 500); // Adjust the delay as needed
  91. }
  92. } else {
  93. this.logToOverlay('VERIFY button not found.');
  94. }
  95. }
  96.  
  97. isMouseLocked = () => {
  98. return document.pointerLockElement === document.body ||
  99. document.mozPointerLockElement === document.body ||
  100. document.webkitPointerLockElement === document.body;
  101. }
  102.  
  103. sendMouseUp = () => {
  104. this.logToOverlay('Mouse is locked, sending mouseup command...');
  105. const mouseUpEvent = new MouseEvent('mouseup', {
  106. bubbles: true,
  107. cancelable: true,
  108. view: window
  109. });
  110. document.body.dispatchEvent(mouseUpEvent);
  111. }
  112.  
  113. observeDOM = () => {
  114. this.logToOverlay('Setting up MutationObserver...');
  115. const observer = new MutationObserver((mutationsList) => {
  116. this.logToOverlay(`Mutation observed... ${mutationsList.length} mutation(s) in total.`);
  117. for (const mutation of mutationsList) {
  118. this.logToOverlay(`Mutation type: ${mutation.type}`);
  119. this.logToOverlay(`Mutation target: ${mutation.target.outerHTML}`);
  120. this.logToOverlay(`Added nodes: ${mutation.addedNodes.length}`);
  121. mutation.addedNodes.forEach((node) => {
  122. if (node instanceof HTMLElement) {
  123. this.logToOverlay(`Added node: ${node.nodeName}`);
  124. // Check if the added node is the VERIFY button
  125. if (node.id === 'interact') {
  126. // Add a slight delay to ensure modal visibility
  127. setTimeout(() => {
  128. // If so, click the button without scrolling
  129. this.clickVerifyButton(node);
  130. // Attempt other ways to click the button
  131. document.querySelector('#modal #interact').click(); // First attempt
  132. document.querySelector('#modal button#interact').click(); // Second attempt
  133.  
  134. // Additional attempts
  135. node.click(); // Third attempt
  136. const customClickEvent = new CustomEvent('click', { bubbles: true });
  137. node.dispatchEvent(customClickEvent); // Fourth attempt
  138. const mouseDownEvent = new MouseEvent('mousedown', { bubbles: true });
  139. node.dispatchEvent(mouseDownEvent);
  140. const mouseUpEvent = new MouseEvent('mouseup', { bubbles: true });
  141. node.dispatchEvent(mouseUpEvent); // Fifth attempt
  142. node.parentElement.click(); // Sixth attempt
  143. console.log(`Attempt ${this.clickCount + 6}: jQuery click`);
  144. $(node).trigger('click'); // Seventh attempt
  145. console.log(`Attempt ${this.clickCount + 7}: Focus and simulate Enter key`);
  146. node.focus();
  147. const keyboardEvent = new KeyboardEvent('keydown', { key: 'Enter' });
  148. node.dispatchEvent(keyboardEvent); // Eighth attempt
  149. const pointerDownEvent = new PointerEvent('pointerdown', { bubbles: true });
  150. node.dispatchEvent(pointerDownEvent);
  151. const pointerUpEvent = new PointerEvent('pointerup', { bubbles: true });
  152. node.dispatchEvent(pointerUpEvent); // Ninth attempt
  153. const touchEvent = new TouchEvent('touchstart', { bubbles: true });
  154. node.dispatchEvent(touchEvent); // Tenth attempt
  155. }, 500); // Adjust the delay as needed
  156. }
  157. }
  158. });
  159. this.logToOverlay(`Removed nodes: ${mutation.removedNodes.length}`);
  160. mutation.removedNodes.forEach((node) => {
  161. this.logToOverlay(`Removed node: ${node.nodeName}`);
  162. });
  163. }
  164. });
  165.  
  166. // Start observing changes in the sc-modal element
  167. this.logToOverlay('Attempting to observe sc-modal element...');
  168. const scModal = document.querySelector('#modal');
  169. if (scModal) {
  170. this.logToOverlay('sc-modal element found. Starting observation...');
  171. observer.observe(scModal, { childList: true, subtree: true });
  172. } else {
  173. this.logToOverlay('sc-modal element not found.');
  174. }
  175. }
  176.  
  177. setupConsoleOverlay = () => {
  178. const consoleOverlay = document.createElement('div');
  179. consoleOverlay.setAttribute('id', 'console-overlay');
  180. consoleOverlay.style.position = 'fixed';
  181. consoleOverlay.style.top = '10px';
  182. consoleOverlay.style.left = '10px';
  183. consoleOverlay.style.backgroundColor = 'rgba(255, 255, 255, 0.9)';
  184. consoleOverlay.style.padding = '10px';
  185. consoleOverlay.style.border = '1px solid #ccc';
  186. consoleOverlay.style.zIndex = '9999';
  187.  
  188. // Minimize button
  189. const minimizeButton = document.createElement('button');
  190. minimizeButton.textContent = 'Minimize';
  191. minimizeButton.style.position = 'absolute';
  192. minimizeButton.style.top = '5px';
  193. minimizeButton.style.right = '5px';
  194. minimizeButton.addEventListener('click', () => {
  195. consoleOverlay.style.display = 'none';
  196. });
  197. consoleOverlay.appendChild(minimizeButton);
  198.  
  199. document.body.appendChild(consoleOverlay);
  200. this.consoleOverlay = consoleOverlay;
  201. }
  202.  
  203. logToOverlay = (message) => {
  204. const logEntry = document.createElement('div');
  205. logEntry.textContent = message;
  206. if (this.consoleOverlay) {
  207. this.consoleOverlay.appendChild(logEntry);
  208. }
  209. console.log(message);
  210. }
  211. }
  212.  
  213. // Start the script
  214. new VerifyScript();