Created
March 13, 2019 17:37
-
-
Save dorukcan/9b8d6ead564169475d0f79166de0213f to your computer and use it in GitHub Desktop.
hide non-badged chat comments
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
function handle_chat() { | |
Array.from(document.querySelectorAll('.video-chat__message-list-wrapper li')).filter(x => { | |
return x.querySelectorAll('[data-a-target="chat-badge"]').length === 0; | |
}).forEach(x => { | |
x.setAttribute('style', 'display: none'); | |
}); | |
} | |
function start_observation() { | |
// Select the node that will be observed for mutations | |
var targetNode = document.querySelector('.video-chat__message-list-wrapper'); | |
// Options for the observer (which mutations to observe) | |
var config = { | |
attributes: true, | |
childList: true, | |
subtree: true | |
}; | |
// Callback function to execute when mutations are observed | |
var callback = function (mutationsList, observer) { | |
for (var mutation of mutationsList) { | |
if (mutation.type == 'childList') { | |
handle_chat() | |
} | |
} | |
}; | |
// Create an observer instance linked to the callback function | |
var observer = new MutationObserver(callback); | |
// Start observing the target node for configured mutations | |
observer.observe(targetNode, config); | |
} | |
start_observation(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment