Links

hide-if-contains-visible-text

The hide-if-contains-visible-text snippet hides any HTML element that matches a CSS selector if the element's visible text content contains a given string.
You can use this snippet to hide an element based on its visible text content.

Parameters

Name
Description
Mandatory
search
The string to match to the visible text. The text is considered visible 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-visible-text snippet:
Filter
Result
hide-if-contains-visible-text FAQ nav
Hides any nav element whose visible 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-visible-text FAQ nav a
Hides any nav element that has an a element inside its subtree whose visible text content contains the word FAQ.
hide-if-contains-visible-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 visible text content matches the /.*/ regex.