LogoLogo
About GitLabAcceptable Ads
  • Getting Started
  • Browser Ad-Filtering Solution
    • Features
    • Getting Started
      • Quickstart
      • Integrate the Solution
      • Set up user counting
    • Guides
      • User counting
      • Configure Solution settings
      • Run separate instances of the filtering engine
      • Update the Solution
      • Understand the snippets library
      • Create a filter list
      • Testing
    • Advanced
      • Services and classes
      • Sitekey
      • ADRs
      • Frame hierarchy
  • Snippets
    • Snippets Overview
    • Behavioral Snippets
      • abort-current-inline-script
      • abort-on-property-read
      • abort-on-property-write
      • abort-on-iframe-property-read
      • abort-on-iframe-property-write
      • array-override
      • cookie-remover
      • freeze-element
      • json-override
      • json-prune
      • override-property-read
      • prevent-listener
      • replace-fetch-response
      • replace-xhr-response
      • simulate-mouse-event
      • skip-video
      • strip-fetch-query-parameter
    • Conditional Hiding Snippets
      • hide-if-canvas-contains
      • hide-if-contains
      • hide-if-contains-image
      • hide-if-contains-similar-text
      • hide-if-contains-visible-text
      • hide-if-contains-and-matches-style
      • hide-if-has-and-matches-style
      • hide-if-labelled-by
      • hide-if-matches-computed-xpath
      • hide-if-matches-xpath
      • hide-if-matches-xpath3
      • hide-if-shadow-contains
    • Debugging Snippets
      • debug
      • log
      • profile
      • trace
    • Performance Snippets
      • race
    • Snippets Support by Platform
    • Node Highlighting
    • Accessing shadow DOM elements
  • Working with filters
  • DATA AND PRIVACY
    • Data collection at eyeo
Powered by GitBook
On this page
  • Parameters
  • Filter examples
  • Other resources

Was this helpful?

Edit on GitLab
Export as PDF
  1. Snippets
  2. Conditional Hiding Snippets

hide-if-matches-xpath3

Last updated 9 months ago

Was this helpful?

The hide-if-matches-xpath3 hides a specific element through a XPath 3.1 query string.

hide-if-matches-xpath3 requires Browser Ad-Filtering Solution version 117+ with Snippet library version 0.8.1+.

hide-if-matches-xpath3 should be used only when hide-if-matches-xpath is not enough for your use case, because it is slower and, at this point in time, not backward compatible with hide-if-matches-xpath.

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-xpath3 snippet:

Filter
Result

hide-if-matches-xpath3 '//*[@id="sponsored"]'

Hides all elements withid="sponsored".

hide-if-matches-xpath3 '//*[lower-case(text())="sponsored"]'

Hides any element that contains the text "sponsored" in its text content, regardless of the element type or the case (upper or lower) of the text (e.g.: "sPoNSoReD").

hide-if-matches-xpath3 '//div and matches(@class,"Spon(.+)sored")]'

Hides all divs with a class containing a value that matches the regular expression pattern "Spon(.+)sored" (e.g.: "Spon12345sored").

Other resources

Getting started with XPath filters
DevHints XPath cheatsheet
CSS to XPath converter
Fonto XPath playground
W3C XPath 3.1 documentation