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. It can also check an unlimited amount of CSS attributes of a node to locate a specific string, even when a website employs methods to obscure or conceal the text.
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 | 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 | No |
optionalParameters | You can provide any number of optional parameters. There are 2 kinds of optional parameters: [1] tuning text matching logic or [2] adding arbitrary CSS attributes.
The optional parameters need to follow these syntax rules:
| No |
Default Parameters
In order to tackle common circumvention patterns, the snippet checks already some styles in the matched element, even if you don't add any optional parameter. You can see the default values in the "Default value" column.
Note that you can override the default parameters by adding them as optional parameter, following the syntax rules explained above. You can give any value, the "How to overwrite" column shows only examples. Adjust the values according to your needs.
Name | Description | Default Value | How to overwrite |
---|---|---|---|
| Used to expand the bounding box of the overflow parent. This is useful if the website is pushing some elements outside of a overflow:hidden parent. Unit is pixels. |
|
|
| Used to disable the check where we categorize elements with the same text color and background color as "not visible". |
|
|
| Used to categorize elements that are pushed outside of a parent even if the parent does not have the style overflow:hidden. |
|
|
| Used to set the pseudo elements (:before , :after etc.) translate threshold. Any pseudo elements that have a transform(translate) value higher than this threshold will be counted as invisible. Unit is pixels. |
|
|
| Used to check if the gibberish text that scrambles the string we are looking for is contained in a transparent element. |
|
|
| Used to check if the gibberish text that scrambles the string we are looking is made invisible by the font-size. |
|
|
| Used to check if the gibberish text that scrambles the string we are looking is made invisible by the font color. |
|
|
Filter examples
The following table lists examples that use the hide-if-contains-visible-text
snippet:
Filter | Result |
---|---|
| Hides any |
| Hides any |
| Hides any |
| Hides any |
Last updated