Advertisement
MeKLiN2

Unignore shutdown fullhomo

Jan 3rd, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.44 KB | None | 0 0
  1. // ==UserScript==
  2. // @name fh
  3. // @namespace http://tampermonkey.net/
  4. // @version 2023-12-29
  5. // @description try to take over the world!
  6. // @author fullhomo
  7. // @match https://www.shutdown.chat/rooms/downtown/*
  8. // @grant GM_openInTab
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. GM_addStyle('#blockedContainer { height:100px; width: 900px; margin: 0 auto;}');
  13. GM_addStyle('#blockedMessages { height:90px; width: 900px; margin: 0 auto;}');
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. if (/child/.test(location.search)) {
  19.  
  20. window.stop();
  21. const xhr = new XMLHttpRequest();
  22. xhr.open('GET', window.location.href);
  23. xhr.onload = () => {
  24. var html = xhr.responseText
  25. .replace(/<script\b[\s\S]*?<\/script>/g, s => {
  26. // check if script tag should be replaced/deleted
  27. if (s.includes('rmp')) {
  28. let regex = /(_rmp\([^,]*,[^,]*,[^,]*,)(?:'[^']*'|[^,]*)(,)/;
  29. let str = s.replace(regex, "$1'0'$2");
  30. regex = /(_fcr\([^,]*,[^,]*,[^,]*,)(?:'[^']*'|"[^"]*"|[^,]*)(,)/;
  31. str = str.replace(regex, "$1'0'$2");
  32. return str;
  33. } else {
  34. return s;
  35. }
  36. });
  37. document.open();
  38. document.write(html);
  39.  
  40. function onDocumentLoaded() {
  41. const chatbox = document.querySelector('.chatbox');
  42. if (!chatbox) {
  43. console.error('Chatbox not found');
  44. return;
  45. }
  46.  
  47. let processedMessages = new Set();
  48.  
  49. const getMessageInfo = (node) => {
  50. const username = node.querySelector('.nm')?.textContent.trim();
  51. const message = node.querySelector('.msg')?.textContent.trim();
  52. return {
  53. username,
  54. message
  55. };
  56. };
  57.  
  58. function handleAllMessages({
  59. username,
  60. message
  61. }) {
  62. console.log(username + " " + message);
  63. window.opener.postMessage(username + ":" + message, "*");
  64. if (processedMessages.has(message)) {
  65. return;
  66. }
  67. processedMessages.add(message);
  68. }
  69.  
  70. const observer = new MutationObserver((mutations) => {
  71. mutations.forEach(({
  72. addedNodes
  73. }) => {
  74. addedNodes.forEach((node) => {
  75. if (node.tagName === 'P') {
  76. const {
  77. username,
  78. message
  79. } = getMessageInfo(node);
  80. if (username && message) {
  81. handleAllMessages({
  82. username,
  83. message
  84. });
  85. }
  86. }
  87. });
  88. });
  89. });
  90.  
  91. observer.observe(chatbox, {
  92. childList: true,
  93. subtree: true
  94. });
  95. document.querySelector(".fccb input").click();
  96. }
  97.  
  98. document.addEventListener('DOMContentLoaded', onDocumentLoaded);
  99.  
  100. document.close();
  101.  
  102. };
  103. xhr.send();
  104. } else if (/blockcheck/.test(location.search)) {
  105. let allMessages = [];
  106. var processedMessages = [];
  107.  
  108. // Function to find and append missing messages
  109. function appendMissingMessages() {
  110.  
  111. // Find messages that are in allMessages but not in processedMessages
  112. let missingMessages = allMessages.filter(message => !processedMessages.includes(message));
  113.  
  114. let messageBox = document.getElementById('blockedMessages');
  115.  
  116. let missingMessagesText = "\n";
  117. missingMessages.forEach(message => {
  118. missingMessagesText += message + '\n';
  119. });
  120.  
  121. messageBox.value = missingMessagesText;
  122. messageBox.scrollTop = messageBox.scrollHeight;
  123.  
  124. }
  125.  
  126. window.addEventListener('message', function(event) {
  127. allMessages.push(event.data);
  128. console.log("Message received from the child: " + event.data); // Message received from child
  129.  
  130. });
  131.  
  132. window.open("https://www.shutdown.chat/rooms/downtown/?child", "mozillaTab");
  133. //GM_openInTab("https://www.shutdown.chat/rooms/downtown/?child",{setParent : true});
  134.  
  135. var divElement = document.createElement('div');
  136. divElement.id = "blockedContainer";
  137.  
  138. var blockedButton = document.createElement("button");
  139. blockedButton.id = "blockedButton";
  140. blockedButton.innerHTML = "showBlockedMessages";
  141. divElement.appendChild(blockedButton);
  142. blockedButton.addEventListener('click', showBlockedMessages);
  143.  
  144.  
  145. let footer = document.getElementById("room_footer");
  146. document.querySelector("#content").insertBefore(divElement, footer);
  147.  
  148. function showBlockedMessages() {
  149. var textbox = document.createElement('textarea');
  150. textbox.id = 'blockedMessages'; //
  151.  
  152.  
  153. document.querySelector("#blockedContainer").appendChild(textbox);
  154. document.querySelector("#blockedButton").style.display = "none";
  155.  
  156.  
  157. setInterval(appendMissingMessages, 1000);
  158.  
  159. const chatbox = document.querySelector('.chatbox');
  160. if (!chatbox) {
  161. console.error('Chatbox not found');
  162. return;
  163. }
  164.  
  165. const getMessageInfo = (node) => {
  166. const username = node.querySelector('.nm')?.textContent.trim();
  167. const message = node.querySelector('.msg')?.textContent.trim();
  168. return {
  169. username,
  170. message
  171. };
  172. };
  173.  
  174. function handleAllMessages({
  175. username,
  176. message
  177. }) {
  178.  
  179. processedMessages.push(username + ":" + message);
  180. }
  181.  
  182. const observer = new MutationObserver((mutations) => {
  183. mutations.forEach(({
  184. addedNodes
  185. }) => {
  186. addedNodes.forEach((node) => {
  187. if (node.tagName === 'P') {
  188. const {
  189. username,
  190. message
  191. } = getMessageInfo(node);
  192. if (username && message) {
  193. handleAllMessages({
  194. username,
  195. message
  196. });
  197. }
  198. }
  199. });
  200. });
  201. });
  202.  
  203. observer.observe(chatbox, {
  204. childList: true,
  205. subtree: true
  206. });
  207.  
  208. }
  209.  
  210. }
  211.  
  212. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement