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

Was this helpful?

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

hide-if-contains-similar-text

Last updated 2 years ago

Was this helpful?

The hide-if-contains-similar-text snippet hides any HTML element based on similar text content.

This snippet uses a pre-sorted for cases where the content has chuffled characters or text.

Parameters

Name
Description
Mandatory

search

The string to match to the similar text. The text is considered similar text assuming it's not hidden by CSS properties or other means. If the string begins and ends with a slash (/), the text in between is treated as a regular expression.

Yes

selector

The CSS selector that an HTML element must match for it to be hidden.

Yes

searchSelector

The CSS selector that an HTML element containing the given string must match; defaults to the value of the selector argument.

No

Filter examples

The following table lists examples that use the hide-if-contains-similar-text snippet:

Filter
Result

hide-if-contains-similar-text FAQ nav

Hides any nav element whose similar text content contains the word FAQ. The word FAQ doesn't need to be found inside the direct children of the nav element; it can be anywhere in its subtree.

hide-if-contains-similar-text FAQ nav a

Hides any nav element that has an a element inside its subtree whose similar text content contains the word FAQ.

hide-if-contains-similar-text /.*/ li.serp-item 'li.serp-item div.label'

Hides any li.serp-item element which has an 'li.serp-item div.label' element inside its subtree whose similar text content matches the /.*/ regex.

Levenstein distance