Created
May 2, 2019 16:42
-
-
Save hadongsoo/49a153eab2334168d28cd0384e378024 to your computer and use it in GitHub Desktop.
kewords block for twitch chat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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