Module: filterEngine

Classes

FilterEngine

Members

(static) filterEngine :module:filterEngine~FilterEngine

The filterEngine object maintains filters for request blocking, element hiding, and snippets.

Type:
Source:
Example
let {contentTypes, filterEngine} = require("adblockpluscore");

await filterEngine.initialize(
  [
    "/annoying-ad^$image",
    "||example.com/social-widget.html^"
  ]
);

let resource = {
  url: "https://ad-server.example.net/annoying-ad.png",
  documentURL: "https://news.example.com/world.html"
};

let filter = filterEngine.match(resource.url, contentTypes.IMAGE,
                                new URL(resource.documentURL).hostname);
console.log(filter); // prints "/annoying-ad^$image"

Methods

(inner) selectModule(type) → (nullable) {object}

Selects the appropriate module for the given filter type.

Parameters:
Name Type Description
type string

The type of a filter. This must be one of "blocking", "allowing", "elemhide", "elemhideemulation", "elemhideexception", and "snippet"; otherwise the function returns null.

Source:
Returns:

The appropriate module for the given filter type.

Type
object