4

Using uBlock Origin, can I hide (eg. display: none) all <article> elements anywhere on example.org that contains links to anywhere on example.com?

example.org/somepath/somepage.html:

...
<article>
...
<a href="http://www.example.com/foo/bar/"><img src="..."/></a>
...
<p><a href="http://www.example.com/abc/def/">Hello World</a></p>
...
</article>
....
1

uBlock origin supports XPath filters. XPath is able to select elements based on child elements, in contrast to CSS selectors:

##:xpath(//article[.//a[contains(@href,"://www.example.com")]])

This filters all articles that contain a link to www.example.com, either http or https.

  • Thanks a lot! XPath is a bit intimidating, but at least there's a possibility! Is there a official, user-friendly tutorial/manual that takes you through the different ways uBlock Origin can be used in common use cases? Using it has something of a threshold. (In particular, I'm wondering how to block tag names that are random-generated.) – forthrin Feb 10 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.