Skip to content

Instantly share code, notes, and snippets.

@hadongsoo
Created May 2, 2019 16:42
Show Gist options
  • Save hadongsoo/49a153eab2334168d28cd0384e378024 to your computer and use it in GitHub Desktop.
Save hadongsoo/49a153eab2334168d28cd0384e378024 to your computer and use it in GitHub Desktop.
kewords block for twitch chat
// ==UserScript==
// @name twitch_user_hide
// @version 1
// @grant none
// @match *://www.twitch.tv/*
// @run-at document-idle
// ==/UserScript==
let blockList = ['specificusername1','specificusername2', 'specifickeywords1'];
window.setTimeout(function () {
console.log('block start');
let target = document.querySelector('.simplebar-content div[role="log"]');
let observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
let chatLine = target.querySelectorAll('.chat-line__message');
let newLine = chatLine[chatLine.length - 1];
blockList.forEach(index => {
if (newLine.textContent.includes(index)) {
console.log(newLine.textContent);
newLine.style.display = "none";
// newLine.remove();
}
});
});
});
let config = { attributes: false, childList: true, characterData: false };
observer.observe(target, config);
}, 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment