How to block HTML elements by text they contain?

0

I'm looking for a way to hide particular text fragments in a browser—all those news about buzzwords of the day. The idea is to hide HTML elements whose inner text contains certain keywords.

I've written a toy Chrome extension that hides text containing words from a closed-ended list. Now I'm looking for a more extensive solution that supports adding/removing words, and, perhaps, smarter filtering.

I haven't found a Chrome extension like this.

Now I have the usual suspects. AdBlock and uBlock. They remove ads by URL. Can they hide elements by inner text?

Or maybe better solutions exist?

Anton Tarasenko

Posted 2017-10-18T15:47:48.347

Reputation: 225

Answers

1

I think jdwolf meant to refer to :-abp-contains() so here's an example filter which on example.com hides an element <foo class="bar"> that contains the text baz:

example.com#?#foo.bar:-abp-contains(baz)

You can find more examples in EasyList by searching for :-abp-contains(. I also created a ticket (see #6069) to create some official documentation for this feature under adblockplus.org/filters.

greiner

Posted 2017-10-18T15:47:48.347

Reputation: 324

0

CustomBlocker

Not uBlock, but it claims to hide objects with keywords:

  • Block tweets with specific hashtags, URL or keywords on Twitter
  • Hide tweets posted by specific apps on Twitter
  • Mute reviews written by specific users on Amazon or other shopping sites
  • Block comments which contain unpleasant or offensive words or tags on Facebook
  • Remove results of specific domains from Google search results
  • Filter videos by titles on YouTube
  • Make ads invisible even if they are displayed in styles of "normal" posts

Anton Tarasenko

Posted 2017-10-18T15:47:48.347

Reputation: 225