Skip to content

Instantly share code, notes, and snippets.

@tonio-m
Created December 6, 2024 15:03
Show Gist options
  • Select an option

  • Save tonio-m/fc987afb7ecb48e19e04e5b190382854 to your computer and use it in GitHub Desktop.

Select an option

Save tonio-m/fc987afb7ecb48e19e04e5b190382854 to your computer and use it in GitHub Desktop.
violentmonkey userscript to hide tweets. If you have friends that spend all day scrolling and still want to spend time with them.
// ==UserScript==
// @name Discord Mute Word Hider
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hide Discord chat messages containing mute words
// @author tonio-m
// @match *://discord.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// List of mute words
const muteWords = [
"https://fxtwitter.com/",
"https://x.com/",
"https://vxtwitter.com/",
"https://twitter.com/",
"https://youtube.com/",
"https://fixupx.com/",
"revistaoeste.com"
];
// Function to check and hide messages with mute words
function hideMutedMessages() {
document.querySelectorAll('div[data-list-item-id^="chat-messages"]').forEach(element => {
const contentElem = element.querySelector('div[id^="message-content"]');
if (contentElem && !element.previousElementSibling?.matches('button')) {
const messageText = contentElem.innerText;
if (muteWords.some(word => messageText.includes(word))) {
let button = document.createElement('button');
button.innerText = 'show/hide';
button.style.display = 'block';
button.addEventListener('click', () => {
element.style.display = element.style.display === 'block' ? 'none' : 'block';
});
element.parentNode.insertBefore(button, element);
element.style.display = 'none';
}
}
});
}
// Monitor changes on the Discord chat for new messages
const observer = new MutationObserver(hideMutedMessages);
observer.observe(document.body, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment