javascript - Hide comments from certain users? -


i'm using chrome extension web override few things , works great. right i'm trying hide comments users on stack overflow doesn't seem working. think it's way comments loaded.

here javascript:

$(function() {     $('.comment-user:contains("devilsadvocate")').closest('.comment').hide(); }); 

if paste $('.comment-user:contains("devilsadvocate")').closest('.comment').hide(); console, hide comments, not when load page normally.

one possible solution use mutationobserver().

this allow listen changes on comments section , react them accordingly. rough implementation can seen below. create observer , provide hide functionality hide of pertinent comments every time there mutation.

then tell observer watch comments section of posts. i'm sure can write more jquery way of doing this. right cares first .comments section finds. listen child changes, attribute changes, , subtree changes well.

var observer = new mutationobserver(function (mutations) {     $('.comment-user:contains("devilsadvocate")').closest('.comment').hide(); });  observer.observe(document.queryselectorall(".comments")[0], {     attributes: true,     childlist: true,     characterdata: true,     subtree: true }); 

i have no idea of performance impacts has , jquery may have own way of watching dom changes. better way aspect oriented programming comments javascript code can call hider after new comment posted or filter comment there.

alternatively, , far can tell unsupportedly, listen events stack exchange api might emit letting know when new comments loaded.

the issue comes don't believe stack exchange client side javascript part of public api changes break code.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -