hide-if-classifies

The hide-if-classifies snippet hides any HTML element (or its ancestors) that match a CSS selector if the element is classified as an ad by a machine learning model.

You can use hide-if-classifies to hide elements based on statistical predictions.

Parameters

NameDescriptionMandatory

model

The name of the model to be used for inference. Must be hosted on https://easylist-downloads.adblockplus.org/models/. Will be downloaded as needed.

Yes

selector

A CSS selector matching all DOM elements to run inference on. If inference results in a positive prediction for any of the matches, the matched element will be hidden. If subSelector is not specified, inference will be run on the entire element.

Yes

subSelector

A CSS selector matching a DOM element within selector. If specified, inference will only be run on the element matched by subSelector while selector will be used for hiding.

No

Filter examples

The following table lists examples that use the hide-if-classifies snippet:

FilterResult

hide-if-classifies blue-groot-1.0.5 .some-class

Hides any element matching .some-class if inference with the ML model blue-groot-1.0.5 results in a positive prediction.

hide-if-classifies blue-groot-1.0.6 .another-class #some-child

Hides any element matching .another-class if inference on its child #some-child with the ML model blue-groot-1.0.6 results in a positive prediction.

Last updated