Meklin Shutdownchat Script

Modified Shutdownchat, unmatched scripts, brace to be thunderstruck

当前为 2023-12-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Meklin Shutdownchat Script
  3. // @version 1
  4. // @description Modified Shutdownchat, unmatched scripts, brace to be thunderstruck
  5. // @author MeKLiN
  6. // @url https://github.com/MeKLiN2
  7. // @match https://www.shutdown.chat/rooms/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=shutdown.chat
  9. // @license MIT
  10. // @grant none
  11. // @exclude https://www.shutdown.chat/profiles/*
  12. // @exclude https://www.shutdown.chat/manage
  13. // @namespace http://tampermonkey.net/
  14. // @run-at document-start
  15. // jshint esversion: 6
  16. // ==/UserScript==
  17.  
  18. // 608972616881592", "473915865480751", "755327001444987" one of these is wally
  19. //
  20. // 956020454044026 sheets alt,
  21. // 648106985166944 reckful
  22. // 625401812235506 snail
  23. // 497479872276396 beema
  24. // 755327001444987 blurr
  25. // 200600422645641 woman
  26. // Add the uuids of the users you want to block here
  27. debugger;
  28. // alert("Hello from MeKLiN!");
  29.  
  30. // document.addEventListener('DOMContentLoaded', function() {
  31.  
  32. var blocked_uuids = JSON.parse(localStorage.getItem('blocked_uuids')) || [];
  33.  
  34. function getNickname(fcuserSpan) {
  35. if (!fcuserSpan) return;
  36.  
  37. // Check if fcuserSpan is a direct child of p
  38. var isDirectChild = fcuserSpan.parentNode.nodeName === "P";
  39. var nickname;
  40.  
  41. if (isDirectChild) {
  42. nickname = fcuserSpan.innerText.replace(/[:\-]/g, '').trim();
  43. } else {
  44. // If not a direct child, assume it's under an anchor tag (a) in the user list
  45. nickname = fcuserSpan.parentNode.querySelector('.fcuser').innerText.replace(/[:\-]/g, '').trim();
  46. }
  47.  
  48. return nickname;
  49. }
  50.  
  51. // Function to handle the new chat messages
  52. function handleNewChatMessages() {
  53. var chatboxElems = document.querySelector('.chatbox').getElementsByTagName('p');
  54. for (var i = 0; i < chatboxElems.length; i++) {
  55. var chatElem = chatboxElems[i];
  56. if (!chatElem.handled) {
  57. chatElem.handled = true;
  58. var fcuserSpan = chatElem.querySelector('.nm.fcuser');
  59. var uuid = fcuserSpan.dataset.uuid;
  60. if (blocked_uuids.includes(uuid)) {
  61. chatElem.style.display = 'none'; // hide the message
  62. }
  63. }
  64. }
  65. }
  66.  
  67. // Call the handleNewChatMessages function on page load and whenever the chatbox is updated
  68. handleNewChatMessages();
  69. document.querySelector('.chatbox').addEventListener('DOMNodeInserted', handleNewChatMessages);
  70.  
  71.  
  72. // Get the chatbox element
  73. var chatbox = document.querySelector(".chatbox");
  74.  
  75. // Create a mutation observer to monitor changes in the chatbox
  76. var observer = new MutationObserver(function(mutations) {
  77. // Loop through the added nodes
  78. mutations.forEach(function(mutation) {
  79. for (var i = 0; i < mutation.addedNodes.length; i++) {
  80. var node = mutation.addedNodes[i];
  81. // Check if the node is a chat message
  82. if (node.nodeName === "P" && node.dataset.t === "c") {
  83. // Get the uuid of the user who sent the message
  84. var uuid = node.querySelector(".nm.fcuser").dataset.uuid;
  85. // Check if the uuid is in the blocked list
  86. if (blocked_uuids.includes(uuid)) {
  87. // Hide the message
  88. node.style.display = "none";
  89. }
  90. }
  91. }
  92. });
  93. });
  94.  
  95. // Start observing the chatbox
  96. observer.observe(chatbox, {childList: true});
  97.  
  98. // Function to block/unblock a user
  99. function blockUser(uuid) {
  100. console.log("blockUser function is called");
  101. var index = blocked_uuids.indexOf(uuid);
  102. if (index !== -1) {
  103. // User is already blocked, so unblock
  104. blocked_uuids.splice(index, 1);
  105. alert("User unblocked!");
  106. } else {
  107. // User is not blocked, so block
  108. blocked_uuids.push(uuid);
  109. alert("User blocked!");
  110. }
  111.  
  112. // Save the updated blocked_uuids to localStorage
  113. localStorage.setItem('blocked_uuids', JSON.stringify(blocked_uuids));
  114. }
  115.  
  116. // Function to create a button to view the ignore list
  117. function createIgnoreListButton() {
  118. console.log("createIgnoreListButton function is called");
  119. var ignoreListButton = document.createElement("button");
  120. ignoreListButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M20 18V8a6 6 0 0 0-12 0v10h12zM12 2C6.48 2 2 6.48 2 12v10h2V12a5.978 5.978 0 0 1 5.985-6H12V2zm8.293 2.293a1 1 0 0 1 1.414 0l1.414 1.414a1 1 0 0 1 0 1.414L19.414 10l3.707 3.707a1 1 0 0 1 0 1.414l-1.414 1.414a1 1 0 0 1-1.414 0L18 13.414l-3.707 3.707a1 1 0 0 1-1.414 0l-1.414-1.414a1 1 0 0 1 0-1.414L14.586 12 10.88 8.293a1 1 0 0 1 0-1.414L12.294 5.465a1 1 0 0 1 1.414 0z"/></svg> View Ignore List`;
  121. ignoreListButton.style.position = "fixed";
  122. ignoreListButton.style.top = "10px";
  123. ignoreListButton.style.left = "10px";
  124. ignoreListButton.addEventListener("click", function () {
  125. // Display the ignore list (you can customize this part)
  126. alert("Ignore List:\n" + blocked_uuids.join(", "));
  127. });
  128.  
  129. document.body.appendChild(ignoreListButton);
  130. }
  131.  
  132. // Call the function to create the ignore list button
  133. createIgnoreListButton();
  134.  
  135.  
  136. // Get the user list element
  137. var userlist = document.querySelector(".userlist");
  138.  
  139. // Create the block and ignore buttons and append them to each user
  140. var users = userlist.querySelectorAll(".fcuser");
  141. users.forEach(function (user) {
  142. var uuid = user.dataset.uuid;
  143.  
  144. // Create the block button
  145. var blockButton = document.createElement("button");
  146. blockButton.innerText = "Block";
  147. blockButton.addEventListener("click", function() {
  148. blockUser(uuid);
  149. });
  150.  
  151. // Create the ignore button with a unique class
  152. var ignoreButton = document.createElement("button");
  153. ignoreButton.innerText = "Ignore";
  154. ignoreButton.setAttribute("data-btntype", "ignore"); // Set a new attribute for identification
  155. ignoreButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"/><path d="M20 18V8a6 6 0 0 0-12 0v10h12zM12 2C6.48 2 2 6.48 2 12v10h2V12a5.978 5.978 0 0 1 5.985-6H12V2zm8.293 2.293a1 1 0 0 1 1.414 0l1.414 1.414a1 1 0 0 1 0 1.414L19.414 10l3.707 3.707a1 1 0 0 1 0 1.414l-1.414 1.414a1 1 0 0 1-1.414 0L18 13.414l-3.707 3.707a1 1 0 0 1-1.414 0l-1.414-1.414a1 1 0 0 1 0-1.414L14.586 12 10.88 8.293a1 1 0 0 1 0-1.414L12.294 5.465a1 1 0 0 1 1.414 0z"/></svg>`;
  156. ignoreButton.style.marginLeft = "5px";
  157. ignoreButton.style.cursor = "pointer";
  158. // Add a unique class to the ignore button
  159. ignoreButton.classList.add("ignoreButtonClass");
  160.  
  161. ignoreButton.addEventListener("click", function () {
  162. blockUser(uuid);
  163. });
  164.  
  165. // Create a container div for the buttons
  166. var buttonContainer = document.createElement("div");
  167. buttonContainer.style.display = "flex";
  168. buttonContainer.style.alignItems = "center";
  169.  
  170. // Append the buttons to the container
  171. buttonContainer.appendChild(blockButton);
  172. buttonContainer.appendChild(ignoreButton);
  173.  
  174. // Append the container to the user element
  175. user.parentElement.appendChild(buttonContainer);
  176. });
  177.  
  178. // usermenu block button event listener:
  179. document.querySelector('.usermenu button[data-btntype="block"]').addEventListener('click', function() {
  180. console.log("User menu block button clicked");
  181. // Assuming you have access to the user's UUID here
  182. var userUUID = "user_uuid_to_block";
  183. blockUser(userUUID);
  184. });
  185.  
  186. // Function to create an ignore button in the user menu
  187. function createIgnoreButton() {
  188. console.log("createIgnoreButton function is called");
  189. var ignoreButton = document.createElement("button");
  190. ignoreButton.innerText = "Ignore";
  191. ignoreButton.setAttribute("data-btntype", "ignore"); // Set a new attribute for identification
  192. ignoreButton.style.display = "block";
  193. ignoreButton.style.marginTop = "5px"; // Adjust the styling as needed
  194. ignoreButton.addEventListener("click", function () {
  195. // Assuming you have access to the user's UUID here
  196. var userUUID = "user_uuid_to_ignore";
  197. blockUser(userUUID);
  198. });
  199.  
  200. // Insert the ignore button into the user menu
  201. var userMenu = document.querySelector('.usermenu');
  202. userMenu.insertBefore(ignoreButton, userMenu.firstChild);
  203. }
  204.  
  205. // Call the function to create the ignore button in the user menu
  206. createIgnoreButton();
  207.  
  208. // Create the ignore list div once and append the content dynamically
  209. var ignoreListDiv = document.createElement("div");
  210. ignoreListDiv.style.position = "fixed";
  211. ignoreListDiv.style.top = "10px";
  212. ignoreListDiv.style.left = "10px";
  213. ignoreListDiv.style.backgroundColor = "white"; // Adjust styling as needed
  214. ignoreListDiv.style.padding = "10px";
  215. ignoreListDiv.style.border = "1px solid black"; // Add border for visibility
  216.  
  217. // Create a heading for the ignore list
  218. var ignoreListHeading = document.createElement("h3");
  219. ignoreListHeading.innerText = "Ignore List";
  220. ignoreListDiv.appendChild(ignoreListHeading);
  221.  
  222. // Create a list to display ignored users
  223. var ignoreList = document.createElement("ul");
  224. ignoreList.style.listStyleType = "none"; // Remove default list styling
  225. ignoreListDiv.appendChild(ignoreList);
  226.  
  227. // Append the ignore list div to the body
  228. document.body.appendChild(ignoreListDiv);
  229.  
  230. // Function to create a list item with the ignore list entry and remove button
  231. function createIgnoreListItem(uuid) {
  232. var listItem = document.createElement("li");
  233. listItem.innerText = uuid;
  234.  
  235. // Create a remove button for each entry
  236. var removeButton = document.createElement("button");
  237. removeButton.innerText = "Remove";
  238. removeButton.addEventListener("click", function () {
  239. // Remove the entry when the button is clicked
  240. removeIgnoreEntry(uuid);
  241. });
  242.  
  243. // Append the remove button to the list item
  244. listItem.appendChild(removeButton);
  245.  
  246. // Append the list item to the ignore list
  247. ignoreList.appendChild(listItem);
  248. }
  249.  
  250. // Populate the ignore list with entries and remove buttons
  251. blocked_uuids.forEach(function (uuid) {
  252. var listItem = document.createElement("li");
  253. listItem.innerText = uuid;
  254.  
  255. // Create a remove button for each entry
  256. var removeButton = document.createElement("button");
  257. removeButton.innerText = "Remove";
  258. removeButton.addEventListener("click", function () {
  259. // Remove the entry when the button is clicked
  260. removeIgnoreEntry(uuid);
  261. });
  262.  
  263. // Append the remove button to the list item
  264. listItem.appendChild(removeButton);
  265.  
  266. // Append the list item to the ignore list
  267. ignoreList.appendChild(listItem);
  268. });
  269.  
  270. // Function to refresh the ignore list display
  271. function refreshIgnoreList() {
  272. // Clear the existing content
  273. ignoreList.innerHTML = "";
  274.  
  275. // Populate the ignore list with entries and remove buttons
  276. blocked_uuids.forEach(function (uuid) {
  277. createIgnoreListItem(uuid);
  278. });
  279. }
  280.  
  281. // Function to handle removing an entry from the ignore list
  282. function removeIgnoreEntry(uuid) {
  283. var index = blocked_uuids.indexOf(uuid);
  284. if (index !== -1) {
  285. // Remove the entry from the ignore list
  286. blocked_uuids.splice(index, 1);
  287. // Refresh the ignore list display after removal
  288. refreshIgnoreList();
  289. }
  290. }
  291.  
  292. // Function to save blocked_uuids to a text file
  293. function saveToTextFile() {
  294. var textToSave = blocked_uuids.join('\n');
  295. var blob = new Blob([textToSave], { type: 'text/plain' });
  296. var link = document.createElement('a');
  297. link.download = 'ignore_list.txt';
  298. link.href = window.URL.createObjectURL(blob);
  299. link.onclick = function () {
  300. document.body.removeChild(link);
  301. };
  302. link.style.display = 'none';
  303. document.body.appendChild(link);
  304. link.click();
  305. }
  306.  
  307. // Function to load blocked_uuids from a text file
  308. function loadFromTextFile() {
  309. var input = document.createElement('input');
  310. input.type = 'file';
  311. input.accept = '.txt';
  312. input.onchange = function (event) {
  313. var file = event.target.files[0];
  314. if (file) {
  315. var reader = new FileReader();
  316. reader.onload = function (e) {
  317. // Parse the content of the file and update blocked_uuids
  318. blocked_uuids = e.target.result.split('\n').map(function (uuid) {
  319. return uuid.trim();
  320. });
  321. // Update the ignore list display
  322. refreshIgnoreList();
  323. };
  324. reader.readAsText(file);
  325. }
  326. };
  327. input.click();
  328. }
  329.  
  330. // ... (rest of your code)
  331.  
  332. // Function to create a button to save and load ignore list
  333. function createSaveLoadButtons() {
  334. var saveButton = document.createElement("button");
  335. saveButton.innerText = "Save to Text File";
  336. saveButton.addEventListener("click", function () {
  337. saveToTextFile();
  338. });
  339.  
  340. var loadButton = document.createElement("button");
  341. loadButton.innerText = "Load from Text File";
  342. loadButton.addEventListener("click", function () {
  343. loadFromTextFile();
  344. });
  345.  
  346. var buttonContainer = document.createElement("div");
  347. buttonContainer.style.marginTop = "10px";
  348. buttonContainer.appendChild(saveButton);
  349. buttonContainer.appendChild(loadButton);
  350.  
  351. // Append the button container to the ignore list div
  352. ignoreListDiv.appendChild(buttonContainer);
  353. }
  354.  
  355. // Call the function to create the save and load buttons
  356. createSaveLoadButtons();