Skip to content

Instantly share code, notes, and snippets.

@simonfalke-01
Last active June 21, 2026 15:33
Show Gist options
  • Select an option

  • Save simonfalke-01/81cd54e9731a800a55a6bda425f9ba9d to your computer and use it in GitHub Desktop.

Select an option

Save simonfalke-01/81cd54e9731a800a55a6bda425f9ba9d to your computer and use it in GitHub Desktop.
Remove !DHLDROP
// ==UserScript==
// @name remove dhldrop messages
// @match https://www.twitch.tv/*
// @match https://dashboard.twitch.tv/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function () {
const blocked = new Set([
"!DHLDROP"
]);
const MESSAGE_SELECTOR =
'[data-a-target="chat-line-message"], .chat-line__message';
function getMessageText(line) {
const msg = line.querySelector('[data-a-target="chat-message-text"]');
if (msg) return msg.textContent.trim();
return line.textContent.trim();
}
function findSafeWrapper(line, blockedText) {
let best = line;
let el = line;
for (let i = 0; i < 5; i++) {
if (!el.parentElement) break;
const parent = el.parentElement;
const rect = parent.getBoundingClientRect();
const messageCount = parent.querySelectorAll(MESSAGE_SELECTOR).length;
const text = parent.textContent || "";
// HARD safety checks: don't ever hide the whole chat panel
if (messageCount > 1) break;
if (rect.height > 180) break;
if (!text.includes(blockedText)) break;
best = parent;
el = parent;
}
return best;
}
function cleanChat() {
document.querySelectorAll(MESSAGE_SELECTOR).forEach(line => {
const text = getMessageText(line);
if (blocked.has(text)) {
const wrapper = findSafeWrapper(line, text);
console.log("[TwitchBlocker] hiding:", text, wrapper);
// hide instead of remove, safer
wrapper.style.display = "none";
}
});
}
const observer = new MutationObserver(cleanChat);
function start() {
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
cleanChat();
setInterval(cleanChat, 1000);
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", start);
} else {
start();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment