Advertisement
MeKLiN2

StumbleChat AutoVerify

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