AdguardTeam / ExtendedCss

A TypeScript library for non-standard element selecting — :contains(), :matches-css(), etc., and applying CSS styles with extended properties.
GNU General Public License v3.0
65 stars 9 forks source link

Some :xpath rules don't work #106

Closed AdamWr closed 4 years ago

AdamWr commented 4 years ago

For example rule like this doesn't work:

ghacks.net#$?#:xpath(//div[@class="user-content"]/div[@class="snippet-clear"]/following-sibling::text()[contains(.,'Advertisement')]) { remove: true; }

or

ghacks.net#?#:xpath(//div[@class="user-content"]/div[@class="snippet-clear"]/following-sibling::text()[contains(.,'Advertisement')])

It should remove "Advertisement" text in this article - https://www.ghacks.net/2020/04/22/vivaldi-3-0-with-adblocker-and-tracker-blocker-released/

Screenshot ![image](https://user-images.githubusercontent.com/29142494/80137135-182d3200-85a3-11ea-96ab-20bd39d539eb.png)

Something like this works:

var el = document.evaluate( `//div[@class="user-content"]/div[@class="snippet-clear"]/following-sibling::text()[contains(.,'Advertisement')]`, document, null, XPathResult.ANY_TYPE, null ).iterateNext();

el.remove();

so I think it should be possible.

Screenshots ![image](https://user-images.githubusercontent.com/29142494/80137208-37c45a80-85a3-11ea-96d2-19d69c611b77.png) ![image](https://user-images.githubusercontent.com/29142494/80137262-4a3e9400-85a3-11ea-9eed-36ef190a475b.png) ![image](https://user-images.githubusercontent.com/29142494/80137296-5aef0a00-85a3-11ea-8ef9-57b9e30dd170.png)
ameshkov commented 4 years ago

@slavaleleka fixing this would be on you after we finish with scriptlets

slavaleleka commented 4 years ago

we should get back to this task when we replace Sizzle

slavaleleka commented 4 years ago

merged into https://github.com/AdguardTeam/ExtendedCss/issues/110

slavaleleka commented 2 years ago

Related: https://github.com/AdguardTeam/ExtendedCss/issues/144