-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xpath selector doesn't work on text()
nodes
#1777
Comments
Text nodes cannot be queried in uBO. |
why not? |
Only HTML Elements are queried by uBO, non-HTML Elements are discarded, so not possible. Support for querying text nodes doesn't exist in Chromium/Firefox either. |
Duplicate of #1654 |
The question should be the other way around, you need to provide cases where that would be genuinely useful in the real world. |
@gorhill facebook ads |
Use |
That's what I went with, but I don't like that approach because it seems less accurate, as in it seems more likely that some completely unrelated div that has the word sponsored in it might get filtered. that's why I try to avoid non-exact matching where I can I also tried it with regex to get an exact match ( I was simply pointing out a feature that wasn't working as expected and provided a minimal example to reproduce it |
You are not reading the documentation properly. Read carefully, especially before opening invalid issues. If you read carefully -- and it's very clearly explained in the documentation -- you would have understood that what you want is |
It appears you purposefully designed your regex to not match, while you avoided to reveal what is under that first |
In any case, you can use |
Not if you narrow down the matches with with other attributes and ancestor nodes.
https://www.reddit.com/r/uBlockOrigin/wiki/solutions#wiki_facebook |
as it says i performed a cursory search. the word "xpath" wasn't in either the title or description of that issue |
Prerequisites
I tried to reproduce the issue when...
Description
xpath selectors don't seem to work on individual text nodes, for example when an element has multiple text nodes and you're trying to match one of them
A specific URL where the issue occurs
n/a but see steps to reproduce for a minimal html file to reproduce
Steps to Reproduce
//p/text()[.='hello2']
##body:has(:xpath(//p/text()[.='hello2']))
Expected behavior
body element is blocked as the
//p/text()[.='hello2']
xpath should match a node within itActual behavior
no match
uBlock Origin version
1.38.6
Browser name and version
edge 94.0.992.50
Operating System and version
windows 10
The text was updated successfully, but these errors were encountered: