Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  span[data-content="S"]
    + span[data-content="p"]
    + span[data-content="o"]
    + span[data-content="n"]
    + span[data-content="s"]
    + span[data-content="o"]
    + span[data-content="r"]
    + span[data-content="e"]
    + span[data-content="d"] {
    display: none;
  }
This only hides the "d", right? You generally can't hide a higher-level element based on drill-down selectors, so pure CSS wouldn't be enough. But of course, finding the appropriate parent by scripting would be trivial from here.

Apart of that, why can't one just accumulate all visible text by filtering out all `display: none` elements? Of course, this could be attacked again by e.g. shrinking the "noise" characters to width 0.



Yeah, I always have to write userscripts to get access to getElementsBy(TagName,Id,etc) and then call .parentNode().parentNode()... to reach the ancestor I want to remove.

Of course the downside of userscripts compared to uBlock rules is that they take time to run, so you end up seeing the ads briefly before they are erased, which is annoying. So then I run the scripts prior to page-load to insert CSS rules to hide all elements that might be ads, let the page load, filter it, and then override the older CSS rules. It's quite a hassle, really.

What I'm saying is, :parent selectors in CSS would be greatly appreciated.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: