Skip to content

Instantly share code, notes, and snippets.

@javajawa
Created October 13, 2019 08:07
Show Gist options
  • Save javajawa/91f60a0ba3bc39983abe5533ba644e2b to your computer and use it in GitHub Desktop.
Save javajawa/91f60a0ba3bc39983abe5533ba644e2b to your computer and use it in GitHub Desktop.
Twitch Chat Filter
// Twitch Chat Filter that hides messags unless they are from mods or in the list of allowed users.
// Originally written, and still configured, for LRR's PPR streams, where I wanted to be able to read the rules text LLRBot put into chat.
(function()
{
const allowed_users = ['LoadingReadyRun', 'LRRbot', 'LRRMTG_Judge'];
const allow_mods = true;
const log = document.querySelector('div[role="log"]');
window.setInterval(() =>
{
log.querySelectorAll('div.chat-line__message:not(.processed)').forEach(e => {
e.classList.add( 'processed' );
if ( allowed_users.includes(e.querySelector('span.chat-line__username').textContent))
{
return;
}
if ( allow_mods && e.querySelector( 'img.chat-badge[aria-label="Moderator badge"]' ) )
{
return;
}
// Uncomment this and remove the line below to only fade out unwanted messages
//e.style.opacity = '0.1';
e.style.display = 'none';
});
}, 500);
})();
!function(d,t){const o=["LoadingReadyRun","LRRbot","LRRMTG_Judge"],a=d[t]('div[role="log"]');window.setInterval(()=>a[t+'All']("div.chat-line__message:not(.processed)").forEach(e=>{e.classList.add("processed"),o.includes(e[t]("span.chat-line__username").textContent)||e[t]('img.chat-badge[aria-label="Moderator badge"]')||(e.style.display="none")}),500)}(document,'querySelector');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment