Skip to content

Instantly share code, notes, and snippets.

@cwillsey06
Last active March 13, 2023 15:12
Show Gist options
  • Select an option

  • Save cwillsey06/dc70addb16f52353e58062989f624cdf to your computer and use it in GitHub Desktop.

Select an option

Save cwillsey06/dc70addb16f52353e58062989f624cdf to your computer and use it in GitHub Desktop.
Discord — hide blocked messages and their "spoiler blocks"
// ==UserScript==
// @name Hide blocked messages
// @namespace https://gist.github.com/cwillsey06
// @version 1.0
// @description Hide blocked messages and their "spoiler blocks"
// @author cwillsey06
// @license Unlicense
// @run-at document-start
// @match *://discord.com/channels/*
// ==/UserScript==
(function () {
'use strict';
let blockedlist = document.querySelectorAll("div[class^='blockedSystemMessage']");
blockedlist.forEach(elem=>(elem.parentElement.parentElement.style.display="none"));
let mutationObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
mutation.addedNodes.forEach( function(currentValue, currentIndex, listObj) {
if (currentValue.nodeType == Node.ELEMENT_NODE) {
let blockedlist = currentValue.querySelectorAll("div[class^='blockedSystemMessage']");
blockedlist.forEach(elem=>(elem.parentElement.parentElement.style.display="none"));
}
});
});
});
mutationObserver.observe(document.documentElement, {
childList: true,
subtree: true
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment