Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name MSS
- // @namespace http://tampermonkey.net/
- // @version 2023-12-29
- // @description Meklin Shutdownchat Script
- // @author MeKLiN
- // @match https://www.shutdown.chat/rooms/downtown
- // @icon https://www.google.com/s2/favicons?sz=64&domain=shutdown.chat
- // @grant none
- // ==/UserScript==
- (function () {
- 'use strict';
- // Get the ignore list from the storage, or use an empty array as the default value
- var blocked_uuids = GM_getValue("ignore_list", []);
- // Get the chatbox element
- var chatbox = document.querySelector(".chatbox");
- // Create a mutation observer to monitor changes in the chatbox
- var observer = new MutationObserver(function(mutations) {
- // Loop through the added nodes
- mutations.forEach(function(mutation) {
- for (var i = 0; i < mutation.addedNodes.length; i++) {
- var node = mutation.addedNodes[i];
- // Check if the node is a chat message
- if (node.nodeName === "P" && node.dataset.t === "c") {
- // Get the uuid of the user who sent the message
- var uuid = node.querySelector(".nm.fcuser").dataset.uuid;
- // Check if the uuid is in the blocked list
- if (blocked_uuids.includes(uuid)) {
- // Hide the message
- node.style.display = "none";
- }
- }
- }
- });
- });
- // Start observing the chatbox
- observer.observe(chatbox, {childList: true});
- // Add a user's uuid to the ignore list, and store it in the storage
- function addToIgnoreList(uuid) {
- // Check if the uuid is already in the ignore list
- if (!blocked_uuids.includes(uuid)) {
- // Add the uuid to the ignore list
- blocked_uuids.push(uuid);
- // Store the ignore list in the storage
- GM_setValue("ignore_list", blocked_uuids);
- }
- }
- // Create a button element for each user in the user list, and set its data-uuid attribute and click event listener
- function createIgnoreButton(user) {
- // Create a button element
- var button = document.createElement("button");
- // Set the button text
- button.textContent = "Ignore";
- // Set the button data-uuid attribute to the same value as the user element
- button.dataset.uuid = user.dataset.uuid;
- // Set the button click event listener
- button.addEventListener("click", function() {
- // Get the uuid from the button data-uuid attribute
- var uuid = this.dataset.uuid;
- // Add the uuid to the ignore list
- addToIgnoreList(uuid);
- // Hide the user element
- user.style.display = "none";
- // Hide the user's messages
- hideUserMessages(uuid);
- });
- // Return the button element
- return button;
- }
- // Hide the user's messages by uuid
- function hideUserMessages(uuid) {
- // Get all the chat messages
- var chatMessages = chatbox.querySelectorAll("p[data-t='c']");
- // Loop through the chat messages
- for (var i = 0; i < chatMessages.length; i++) {
- var message = chatMessages[i];
- // Get the uuid of the user who sent the message
- var messageUuid = message.querySelector(".nm.fcuser").dataset.uuid;
- // Check if the uuid matches the one to hide
- if (messageUuid === uuid) {
- // Hide the message
- message.style.display = "none";
- }
- }
- }
- // Create a mutation observer to monitor changes in the user menu
- var userMenuObserver = new MutationObserver(function(mutations) {
- // Loop through the mutations
- mutations.forEach(function(mutation) {
- // Check if the user menu is visible
- if (mutation.target.style.display !== 'none') {
- // Get the user element
- var user = mutation.target.querySelector("h1");
- // Create the button element
- var button = createIgnoreButton(user);
- // Set the button z-index to 1
- button.style.zIndex = "1";
- // Set the button style to make it bigger
- button.style.fontSize = "20px";
- button.style.padding = "10px";
- // Append the button element to the user menu
- mutation.target.appendChild(button);
- }
- });
- });
- // Get the user menu element
- var userMenu = document.querySelector(".usermenu");
- // Start observing the user menu
- userMenuObserver.observe(userMenu, {attributes: true, attributeFilter: ['style']});
- // Create a symbol element that can show the ignore list
- function createIgnoreSymbol() {
- // Create a symbol element
- var symbol = document.createElement("span");
- // Set the symbol text to an eye with a slash icon
- symbol.textContent = "🙈";
- // Set the symbol title to "Show ignore list"
- symbol.title = "Show ignore list";
- // Set the symbol style
- symbol.style.cursor = "pointer";
- symbol.style.marginLeft = "0.5em";
- // Set the symbol click event listener
- symbol.addEventListener("click", function() {
- // Toggle the visibility of the ignore list
- toggleIgnoreList();
- });
- // Return the symbol element
- return symbol;
- }
- // Create a div element that can display the ignore list
- function createIgnoreList() {
- // Create a div element
- var list = document.createElement("div");
- // Set the list id to "ignore-list"
- list.id = "ignore-list";
- // Set the list style
- list.style.position = "fixed";
- list.style.top = "0";
- list.style.right = "0";
- list.style.width = "300px";
- list.style.height = "100%";
- list.style.backgroundColor = "white";
- list.style.borderLeft = "1px solid black";
- list.style.overflowY = "auto";
- list.style.zIndex = "9999";
- list.style.display = "none";
- // Set the list content
- list.innerHTML = "<h3>Ignore List</h3><ul></ul>";
- // Return the list element
- return list;
- }
- // Toggle the visibility of the ignore list
- function toggleIgnoreList() {
- // Get the ignore list element
- var list = document.getElementById("ignore-list");
- // Check if the list is hidden
- if (list.style.display === "none") {
- // Show the list
- list.style.display = "block";
- // Update the list content
- updateIgnoreList();
- } else {
- // Hide the list
- list.style.display = "none";
- }
- }
- // Update the list content with the ignore list
- function updateIgnoreList() {
- // Get the ignore list element
- var list = document.getElementById("ignore-list");
- // Get the list ul element
- var ul = list.querySelector("ul");
- // Clear the ul content
- ul.innerHTML = "";
- // Loop through the ignore list
- for (var i = 0; i < blocked_uuids.length; i++) {
- var uuid = blocked_uuids[i];
- // Create a li element
- var li = document.createElement("li");
- // Set the li text to the uuid
- li.textContent = uuid;
- // Append the li element to the ul element
- ul.appendChild(li);
- }
- }
- // Call the function when the page loads
- window.addEventListener('load', addIgnoreButtons);
- // Append the symbol element and the list element to the document body
- document.body.appendChild(createIgnoreSymbol());
- document.body.appendChild(createIgnoreList());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement