brave / brave/adblock-rust

has-text selector does not work

Open
#537 4 comments 4 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.8k
Forks
250
Avg merge
1d 16h
Merged PRs (30d)
6

Description

It seems you do have support for the `has-text` selector?

https://github.com/brave/adblock-rust/blob/1bf068dbe186d89b3720c8c1ae59525ffde660fe/tests/unit/filters/cosmetic.rs#L714-L720

But this does not seem to work in Brave? Anything with `:has-text(...)` in it does not seem to parse correctly?

It's incredibly hard to tell what's going on - in the "block element" dialog, there is no indication of whether or not your selector is even valid. You can't tell if your selector has a syntax error, or it just doesn't match any elements. I don't understand how people develop or test filters for this ad blocker? Is this really the best/only tool we have for this?

(I want to block "Reels" on facebook, but there are literally no stable selectors to be had anywhere on the page - every single ID and class name are generated at build-time and will change with their next deployment. The only reasonably stable selector would be a text selector. I know this would have performance implications.)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with tests/unit/filters/cosmetic.rs around lines 714-720 and reproduce the reported :has-text(...) behavior in Brave. Trace whether the selector parses and matches as expected, and determine how the block element dialog should distinguish invalid selectors from selectors with no matches. Done means the intended selector behavior is covered by tests and the reported failure is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.