Skip to content

Instantly share code, notes, and snippets.

@idb-
Last active May 29, 2020 05:33
Show Gist options
  • Save idb-/21168cbc7adb3e3034225855dc9a43ba to your computer and use it in GitHub Desktop.
Save idb-/21168cbc7adb3e3034225855dc9a43ba to your computer and use it in GitHub Desktop.
var quit = false;
var interval = 100;
var injected = false;
var processed = [];
function injectCss() {
var style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode('.stfu { display: none!important; }'));
var head = document.head || document.getElementsByTagName('head')[0];
head.appendChild(style);
injected = true;
}
function clearBlockedMessages() {
var blocked = document.querySelectorAll("div[class^='blockedMessageText-']");
if (blocked) {
for (var i = 0; i < blocked.length; i++) {
var container = findContainer(blocked[i]);
if (container && (!processed.includes(container.className))) {
container.classList.add("stfu");
processed.push(container.className);
}
}
}
}
function findContainer(el) {
var previous = el.parentElement;
if (previous == null) return null;
if (previous.hasAttribute("class") && previous.className.match(/^groupStart-/)) {
if (!previous.className.indexOf('stfu') > -1) {
return previous;
} else {
return null;
}
} else {
return findContainer(previous);
}
}
var stfuGray = setInterval(function() {
if (!injected) injectCss();
if (injected) clearBlockedMessages();
if (quit)
clearInterval(stfuGray);
}, interval);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment