hide-if-matches-xpath

hide-if-matches-xpath

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

Parameters

Name

Description

Mandatory

query

The XPath query that targets the element to hide.

Yes

scopeQuery

XPath query defining the scope of the Mutation Observer. Be as specific as possible.

No

waitUntil

Delay until given state (loading, interactive, complete, load, or event name).

No

Filter examples

Filter

Result

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

Hides all elements.

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

Hides the element with id="Ad".

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

Hides all elements with class ad-container.

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

Waits until document is complete before hiding.

Always use double-quotes instead of single-quotes inside selectors.

Other resources