hide-if-contains-similar-text

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

This snippet uses a pre-sorted Levenstein distance 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.

Last updated