I'm trying to block certain results from appearing on my Google searches but I'm having a hard time concisely creating a one-line block using uBlock Origin.
For example, I don't want 'www. imyfone.com' from appearing in my search results because they are trying to sell me products when rather, I'm looking for a solution that I can solve myself.
So, after a few attempts, I was able to narrow down to 2 entries to remove the website from appearing:
*[contains(@href,'www.imyfone.com')][@jsname]/ancestor::div[@jsaction][@jscontroller]/..
and
*[contains(@href,'www.imyfone.com')][@jsname]/ancestor::div[@class='hlcw0c']
Despite the progress, I can't figure out how to combine the two. The issue comes down to how the two results are structured. For one result, if the result relates to the very thing I'm searching, verbatim, the result will be bigger and have a different structure relative to other related results.
I tried using the following but it only gets to <a>link</a> for the large results.
*[contains(@href,'www.imyfone.com')][@jsname][ancestor::div[@jsaction][@jscontroller]/.. or ancestor::div[@class='hlcw0c']]
I tried this but it was too greedy/encompassing to the point of removing the whole page.
*[contains(@href,'www.imyfone.com')][@jsname]/ancestor::div[((@class='MjjYud') or (@jsaction and @jscontroller))]/..
I tried narrowing the last one with and not but whatever I tried, it was ignored.
*[contains(@href,'www.imyfone.com')][@jsname]/ancestor::div[((@class='MjjYud') or (@jsaction and @jscontroller) and not(@id='rso' and @id='rcnt'))]
Could someone help me get better with XPATH? Thanks!
I might be missing something, but can't you simply combine the two expressions with the union operator ('|')?
You haven't told us which XPath version you are using, I'm guessing it's probably 1.0.
In XPath 2.0+ you can use the union operator in any step of the path, so
In XPath 1.0 it can only appear at the top level, which is rather more verbose: