hide-if-matches-xpath

The hide-if-matches-xpath snippet hides specific elements through an XPath 1.0 query string.

You can use the hide-if-matches-xpath snippet to hide an element based on its children or siblings. This snippet also lets you use flexible queries to hide elements.

Always use double-quotes instead of single-quotes inside selectors. While both are valid, eyeo uses single-quotes for enclosing a selector as part of the filter syntax.

Parameters

Name
Description
Mandatory

query

The XPath query that targets the element to hide.

Yes

scopeQuery

XPath selector that the filter devs can use to restrict the scope of the Mutation Observer. It is important that the selector is as specific as possible to avoid to match too many nodes.

No

Filter examples

The following table lists examples that use the hide-if-matches-xpath snippet:

Filter
Result

hide-if-matches-xpath '//*'

Hides all elements.

hide-if-matches-xpath '//*[@id="Ad"]'

Hides the element with the id of Ad.

hide-if-matches-xpath '//*[contains(concat(" ",normalize-space(@class)," ")," ad-container ")]'

Hides all elements with a class named ad-container.

Other resources

Last updated