Advertisement
MeKLiN2

Untitled

Jan 27th, 2024
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.89 KB | None | 0 0
  1. // ==UserScript==
  2. // @name !HSSSysMsg
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description HELL STUMBLECHAT SCRIPT
  6. // @author MeKLiN
  7. // @match https://stumblechat.com/room/*
  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. (function() {
  15. let css = `
  16. .message .nickname ~ .content {
  17. display: inline-block;
  18. top: -7px;
  19. position: relative;
  20. margin-left: 2px;
  21. margin-right: 1em;
  22. }
  23. .content + .content {
  24. display: inline-block!important;
  25. margin-right: 1em;
  26. }
  27. .message .nickname ~ .content span {
  28. line-height: 1.5em;
  29. }
  30. `;
  31. if (typeof GM_addStyle !== "undefined") {
  32. GM_addStyle(css);
  33. } else {
  34. let styleNode = document.createElement("style");
  35. styleNode.appendChild(document.createTextNode(css));
  36. (document.querySelector("head") || document.documentElement).appendChild(styleNode);
  37. }
  38. })();
  39.  
  40. var scripts = document.getElementsByTagName("script");
  41. var script = null;
  42. var found = false;
  43.  
  44. for (var i = 0; i < scripts.length; i++) {
  45. script = scripts[i];
  46. if (/^jQuery.*\.js$/i.test(script.src)) {
  47. found = true;
  48. break;
  49. }
  50. }
  51.  
  52. if (!found) {
  53. try {
  54. $ || jQuery || $ === jQuery;
  55. found = true;
  56. } catch (err) {
  57.  
  58. }
  59. }
  60.  
  61. if (!found) {
  62. // inject jQuery.
  63. script = document.createElement("script");
  64. script.type = "text/javascript";
  65.  
  66. var protocol = /^https:/i.test(document.location) ? "https" : "http";
  67. script.src = protocol + "://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
  68. document.getElementsByTagName("body")[0].appendChild(script);
  69. }
  70.  
  71. // Define App globally
  72. window.App = {
  73. Init: () => {
  74. // Define the behavior of App.Init() here
  75. console.log('App.Init() called');
  76. }
  77. };
  78.  
  79. class VerifyScript {
  80. constructor() {
  81. this.observeDOM();
  82. this.setupConsoleOverlay();
  83. this.clickCount = 0;
  84. }
  85.  
  86. clickVerifyButton = (verifyButton) => {
  87. this.clickCount++;
  88. this.logToOverlay(`Attempting to click VERIFY button ${this.clickCount} time(s)...`);
  89. if (verifyButton) {
  90. this.logToOverlay('VERIFY button found.');
  91. // Remove any existing event listeners on the button
  92. verifyButton.removeEventListener('click', this.clickVerifyButton);
  93. // Manually create and dispatch a click event
  94. const clickEvent = new MouseEvent('click', {
  95. bubbles: true,
  96. cancelable: true,
  97. view: window
  98. });
  99. this.logToOverlay('Before dispatchEvent');
  100. verifyButton.dispatchEvent(clickEvent);
  101. this.logToOverlay('After dispatchEvent');
  102.  
  103. if (this.clickCount < 3) {
  104. setTimeout(() => {
  105. if (this.isMouseLocked()) {
  106. this.sendMouseUp();
  107. }
  108. this.clickVerifyButton(verifyButton);
  109. }, 500); // Delay between clicks
  110. } else if (this.clickCount === 3) {
  111. // After the third click, call App.Init()
  112. this.logToOverlay('Third click completed, calling App.Init()...');
  113. setTimeout(() => {
  114. this.logToOverlay('Calling App.Init()...');
  115. App.Init();
  116. }, 500); // Adjust the delay as needed
  117. }
  118. } else {
  119. this.logToOverlay('VERIFY button not found.');
  120. }
  121. }
  122.  
  123. isMouseLocked = () => {
  124. return document.pointerLockElement === document.body ||
  125. document.mozPointerLockElement === document.body ||
  126. document.webkitPointerLockElement === document.body;
  127. }
  128.  
  129. sendMouseUp = () => {
  130. this.logToOverlay('Mouse is locked, sending mouseup command...');
  131. const mouseUpEvent = new MouseEvent('mouseup', {
  132. bubbles: true,
  133. cancelable: true,
  134. view: window
  135. });
  136. document.body.dispatchEvent(mouseUpEvent);
  137. }
  138.  
  139. observeDOM = () => {
  140. this.logToOverlay('Setting up MutationObserver...');
  141. const observer = new MutationObserver((mutationsList) => {
  142. this.logToOverlay(`Mutation observed... ${mutationsList.length} mutation(s) in total.`);
  143. for (const mutation of mutationsList) {
  144. this.logToOverlay(`Mutation type: ${mutation.type}`);
  145. this.logToOverlay(`Mutation target: ${mutation.target.outerHTML}`);
  146. this.logToOverlay(`Added nodes: ${mutation.addedNodes.length}`);
  147. mutation.addedNodes.forEach((node) => {
  148. if (node instanceof HTMLElement) {
  149. this.logToOverlay(`Added node: ${node.nodeName}`);
  150. // Check if the added node is a system message
  151. if (node.classList.contains('system')) {
  152. // Move the system message to the system message window
  153. systemMessageWindow.appendChild(node.cloneNode(true));
  154. }
  155. }
  156. });
  157. this.logToOverlay(`Removed nodes: ${mutation.removedNodes.length}`);
  158. mutation.removedNodes.forEach((node) => {
  159. this.logToOverlay(`Removed node: ${node.nodeName}`);
  160. });
  161. }
  162. });
  163.  
  164. // Start observing changes in the chat content
  165. this.logToOverlay('Attempting to observe chat content...');
  166. const chatContent = document.querySelector('#chat-content');
  167. if (chatContent) {
  168. this.logToOverlay('Chat content found. Starting observation...');
  169. observer.observe(chatContent, { childList: true });
  170. } else {
  171. this.logToOverlay('Chat content not found.');
  172. }
  173. }
  174.  
  175. setupConsoleOverlay = () => {
  176. // Setup console overlay as before
  177. // ...
  178. }
  179.  
  180. logToOverlay = (message, target = this.consoleOverlay) => {
  181. const logEntry = document.createElement('div');
  182. logEntry.textContent = message;
  183. if (target) {
  184. target.appendChild(logEntry);
  185. }
  186. console.log(message);
  187. }
  188. }
  189.  
  190. // Start the script
  191. new VerifyScript();
  192.  
  193. // Create draggable div window for system messages
  194. const systemMessageWindow = document.createElement('div');
  195. systemMessageWindow.classList.add('system-message-window');
  196. systemMessageWindow.style.position = 'fixed';
  197. systemMessageWindow.style.top = '20px';
  198. systemMessageWindow.style.right = '20px';
  199. systemMessageWindow.style.background = 'rgba(255, 255, 255, 0.9)';
  200. systemMessageWindow.style.border = '1px solid #ccc';
  201. systemMessageWindow.style.padding = '10px';
  202. systemMessageWindow.style.cursor = 'move';
  203. systemMessageWindow.style.maxWidth = '400px'; // Limit the width to prevent infinite length
  204. systemMessageWindow.innerHTML = 'System Messages Window';
  205.  
  206. // Make the window draggable
  207. let isDragging = false;
  208. let offsetX, offsetY;
  209. systemMessageWindow.addEventListener('mousedown', e => {
  210. isDragging = true;
  211. offsetX = e.clientX - systemMessageWindow.getBoundingClientRect().left;
  212. offsetY = e.clientY - systemMessageWindow.getBoundingClientRect().top;
  213. });
  214.  
  215. document.addEventListener('mousemove', e => {
  216. if (isDragging) {
  217. const x = e.clientX - offsetX;
  218. const y = e.clientY - offsetY;
  219. systemMessageWindow.style.left = `${x}px`;
  220. systemMessageWindow.style.top = `${y}px`;
  221. }
  222. });
  223.  
  224. document.addEventListener('mouseup', () => {
  225. isDragging = false;
  226. });
  227.  
  228. // Append the window to the body
  229. document.body.appendChild(systemMessageWindow);
  230.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement