News for hackers. Stuff that matters.

Ask HN: How do I hide a user's comments?

Hi,

I don't think HN has this capability so I was trying to craft something via ublock origin.

I added:

news.ycombinator.com##div:has(a[href*="user?id=example"])

however, that only hid the div where the user's name was shown, not the comment itself as that's in another subsequent div. Is there an argument I can pass so that it will hide the next div as well?

Some context on why I'm trying to achieve this - there's a small subset of users that insert political comments in highly interesting threads and I'm trying to avoid politics as much as possible so I'd like to "ban" those users by automatically hiding everything they say. I know it's a sledgehammer approach but the vast majority of HN content is extremely interesting and I really enjoy being part of the community.

Thank you.

( 11 comments | 2 points | on HN )
Re:Ask HN: How do I hide a user's comments? by thomassmith65 on Sunday July 03, 2022 @08:46AM (#31967293)
I use this in ViolentMonkey

  for (let idiot of ['alice','bob','carol','dick','eve']){
      for ( let a of document.querySelectorAll('a[href="user?id=' + idiot + '"]') ){
          let node = a.parentNode.parentNode.parentNode.parentNode
          if (node.tagName !== 'TABLE') { node.style.display = 'none' }
      } 
  }
Re:Ask HN: How do I hide a user's comments? by ogeiczvm on Sunday July 03, 2022 @09:07AM (#31967423)
thank you - I already had GreaseMonkey installed (for old.reddit.com redirection) - wasn't sure if they're compatible but they are - it worked nicely without any modifications - thank you very much. depending on the size of the list this may be cleaner than the ublock origin one - thanks again.
Re:Ask HN: How do I hide a user's comments? by thomassmith65 on Sunday July 03, 2022 @09:16AM (#31967481)
No problem. I can't remember any longer why I excluded 'TABLE' nodes; I think it's to leave the front page alone when it contains posts from the unwanted users. I was only concerned with hiding comments, not links.
Re:Ask HN: How do I hide a user's comments? by lovelearning on Sunday July 03, 2022 @09:02AM (#31967395)
I think you just have to select the right ancestor element.

    news.ycombinator.com##.athing:has(a[href="user?id=example"])
seems to work.
Re:Ask HN: How do I hide a user's comments? by ogeiczvm on Sunday July 03, 2022 @09:06AM (#31967417)
of course, in retrospective now it makes sense - thanks for taking the time to look into this, appreciate it.
Re:Ask HN: How do I hide a user's comments? by water8 on Sunday July 03, 2022 @07:31AM (#31966902)
You grow up and learn to accept that there are lots of unsavory things in this world. Part of being mature means facing difficult things instead of hiding them or running away from them
Re:Ask HN: How do I hide a user's comments? by krapp on Sunday July 03, 2022 @07:01PM (#31971741)
On the contrary, when you actually grow up you realize life is too short and your time has value, and you no longer feel obliged to entertain every fool and asshole who wanders by.
Re:Ask HN: How do I hide a user's comments? by water8 on Saturday July 09, 2022 @09:24AM (#32034846)
If you dismiss every single person on a rapid judgment you’re going to go through a lot of people
Re:Ask HN: How do I hide a user's comments? by paulcole on Sunday July 03, 2022 @04:02PM (#31970543)
Seeing shitposts on HN from bozos like myself isn’t the character building exercise in stoicism that you think it is.
Re:Ask HN: How do I hide a user's comments? by water8 on Saturday July 09, 2022 @09:25AM (#32034855)
Nor is it the trauma inducing scourge of society that really needs sheltering from
Re:Ask HN: How do I hide a user's comments? by krapp on Sunday July 03, 2022 @07:16AM (#31966837)
Install a browser plugin or userscript with that capability.