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.
Parameters
query
The XPath query that targets the element to hide.
Yes
scopeQuery
XPath query that defines the scope of the Mutation Observer. It is crucial for the selector to be as specific as possible to prevent matching an excessive number of nodes.
If the scopeQuery fails to find a match, the Mutation Observer will default to being attached to the document
.
No
waitUntil
Optional parameter that can be used to delay the running of the snippet until the given state is reached. Accepts: loading, interactive, complete, load or any event name.
No
Filter examples
The following table lists examples that use the hide-if-matches-xpath
snippet:
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
.
hide-if-matches-xpath '//*[@id="Ad"]' '' complete
Waits until the document state is complete
before hiding elements with the id of Ad
.
Observations
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.
Other resources
Last updated