Skip to content

Loading…

How to block text in elements? #1369

Closed
davidhedlund opened this Issue · 3 comments

2 participants

@davidhedlund

Forum spam is common but can be prevented by blocking specific text (ex "Spam goes here" or "<div>User bar*</div>" below). Can uBlock do that?

Example:

<div>User foo: I think I just solve it.</div>
<div>User bar: Exellent!

Spam goes here</div>
@ghost

Element hiding is done by injecting CSS before the page loads.

There is no CSS selector for "text content matching". Adding support for such a feature would require javascript (search for all elements, then search for the text in them) instead of CSS, would be VERY slow (would noticeably slow down page loading), and would violate the adblock CSS format.

Therefore this isn't doable and will probably never be added.

Defeating spam is the job of the site owners, not addons.

@seanrand

If you want to filter based on specific words contained in text e.g. "spam", this is not possible to do with uBlock, which uses the AdBlock Plus filter syntax for element hiding.

To expand on this a bit, there was a draft for a :contains() selector in CSS3 which would have made this possible, but the proposal apparently didn't make it into the specs.
Extending AdBlock Plus's filter syntax to allow XPaths would make this sort of filtering possible, but neither AdBlock Plus or uBlock support this due to performance and other reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.