Skip to content

Instantly share code, notes, and snippets.

@dorukcan
Created March 13, 2019 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dorukcan/9b8d6ead564169475d0f79166de0213f to your computer and use it in GitHub Desktop.
Save dorukcan/9b8d6ead564169475d0f79166de0213f to your computer and use it in GitHub Desktop.
hide non-badged chat comments
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