uBlock origin: Hide elements containing a certain element

Recently I had the need to hide elements on some web page, but only if they contain a certain other element: Hide all list items that have a div with class="premium".

I use Firefox with uBlock origin for advertisement blocking. Beside ad blocking, it also helps to keep sanity on the web by hiding unnecessary elements like the "hot network questions" list on Stack Overflow.

The normal filter rules used by uBlock are CSS selectors, which do not allow selecting elements based on child tags.

Fortunately, uBlock supports XPath filters which specifically have this feature. The resulting filter rule was easy to write:


heise+ filtering

I use this to filter "heise plus" articles on the main heise.de page, since I do not have a login there and do not need teasers:


Written by Christian Weiske.

Comments? Please send an e-mail.