Class: BlockingFilter

(private) filterClasses.BlockingFilter(text, regexpSource, contentTypeopt, matchCaseopt, domainsopt, thirdPartyopt, sitekeysopt, headeropt, nullable, rewriteopt, nullable, cspopt, nullable)

Class for blocking filters

Constructor

(private) new BlockingFilter(text, regexpSource, contentTypeopt, matchCaseopt, domainsopt, thirdPartyopt, sitekeysopt, headeropt, nullable, rewriteopt, nullable, cspopt, nullable)

Parameters:
Name Type Attributes Description
text string

see Filter()

regexpSource string

see URLFilter()

contentType number <optional>

see URLFilter()

matchCase boolean <optional>

see URLFilter()

domains string <optional>

see URLFilter()

thirdParty boolean <optional>

see URLFilter()

sitekeys string <optional>

see URLFilter()

header HttpHeader <optional>
<nullable>

see URLFilter()

rewrite string <optional>
<nullable>

The name of the internal resource to which to rewrite the URL. e.g. if the value of the $rewrite option is abp-resource:blank-html, this should be blank-html.

csp string <optional>
<nullable>

Content Security Policy to inject when the filter matches

Source:

Extends

Members

contentType :number

Content types the filter applies to, combination of values from module:contentTypes.contentTypes

Type:
  • number
Overrides:
Source:

(nullable) csp :string

Content Security Policy to inject for matching requests.

Type:
  • string
Source:

disabled :boolean

Defines whether the filter is disabled globally.

Type:
  • boolean
Overrides:
Deprecated:
Source:

disabledSubscriptions :Set.<string>

Defines which subscriptions the filter is disabled for. See module:filterClasses.ActiveFilter#isDisabledForSubscription and module:filterClasses.ActiveFilter#setDisabledForSubscription for disabling and enabling filters.

Type:
  • Set.<string>
Overrides:
Source:

(nullable) domains :Map.<string, boolean>

Map containing domains that this filter should match on/not match on or null if the filter should match on all domains

Type:
  • Map.<string, boolean>
Overrides:
Source:

domainSeparator

Overrides:
Source:
See:
  • ActiveFilter.domainSeparator

(nullable) domainSource :string

String that the domains property should be generated from

Type:
  • string
Overrides:
Source:

Header-based filtering expression. Refer to the filter documentation reference for the syntax, or BlockingFilter.filterHeaders for the reference implementation.

Type:
  • HttpHeader
Overrides:
Source:

hitCount :number

Number of hits on the filter since the last reset

Type:
  • number
Overrides:
Source:

lastHit :number

Last time the filter had a hit (in milliseconds since the beginning of the epoch)

Type:
  • number
Overrides:
Source:

matchCase :boolean

Defines whether the filter should distinguish between lower and upper case letters

Type:
  • boolean
Overrides:
Source:

(nullable) pattern :string

Expression from which a regular expression should be generated - for delayed creation of the regexp property.

Undefined if the filter uses a regex literal pattern.

Type:
  • string
Overrides:
Deprecated:
Source:

regexp :RegExp

Regular expression to be used when testing against this pattern

Type:
  • RegExp
Overrides:
Deprecated:
Source:

requiresPrivilegedSubscription :bool

True if filter should only be loaded if it comes from a privileged subscription (circumvention subscriptions or special subscriptions).

Type:
  • bool
Overrides:
Source:

(nullable) rewrite :string

The name of the internal resource to which to rewrite the URL. e.g. if the value of the $rewrite option is abp-resource:blank-html, this should be blank-html.

Type:
  • string
Overrides:
Source:

sitekeys

Overrides:
Source:
See:
  • ActiveFilter.sitekeys

sitekeySource

Overrides:
Source:
See:
  • ActiveFilter.sitekeySource

size :number

Number of filters contained, will always be 1 (required to optimize Matcher).

Type:
  • number
Overrides:
Source:

(nullable) thirdParty :boolean

Defines whether the filter should apply to third-party or first-party content only. Can be null (apply to all content).

Type:
  • boolean
Overrides:
Source:

type :string

Filter type as a string, e.g. "blocking".

Can be blocking, allowing, elemhide, elemhideexception, elemhideemulation, snippet, comment or invalid.

Type:
  • string
Overrides:
Source:

urlPattern :Pattern

Pattern for matching request URLs

Type:
  • Pattern
Overrides:
Source:

Methods

filterHeaders(headers) → {boolean}

Filter headers.

This function would be called by the request blocker code after matching the request.

Parameters:
Name Type Description
headers webRequest.HttpHeaders

the HTTP response headers to match, as they are returned by the request blocker. They follow the API https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/HttpHeaders.

Source:
Returns:

Whether the headers match. Will return true if there is nothing to match against, or if the header is present but no value.

Type
boolean

isActiveOnDomain(docDomainopt, nullable, sitekeyopt) → {boolean}

Checks whether this filter is active on a domain.

Parameters:
Name Type Attributes Description
docDomain string <optional>
<nullable>

domain name of the document that loads the URL

sitekey string <optional>

public key provided by the document

Overrides:
Source:
Returns:

true in case of the filter being active

Type
boolean

isActiveOnlyOnDomain(docDomainopt, nullable) → {boolean}

Checks whether this filter is active only on a domain and its subdomains.

Parameters:
Name Type Attributes Description
docDomain string <optional>
<nullable>
Overrides:
Source:
Returns:
Type
boolean

isDisabledForSubscription(subscriptionUrl) → {boolean}

Checks whether this filter is disabled.

Parameters:
Name Type Description
subscriptionUrl string

The subscription to check for enabled / disabled state.

Overrides:
Source:
Returns:

true if the filter is disabled

Type
boolean

isGeneric() → {boolean}

Checks whether this filter is generic or specific

Overrides:
Source:
Returns:
Type
boolean

matches(request, typeMask, sitekeyopt, nullable) → {boolean}

Tests whether the URL request matches this filter

Parameters:
Name Type Attributes Description
request module:url.URLRequest

URL request to be tested

typeMask number

bitmask of content / request types to match

sitekey string <optional>
<nullable>

public key provided by the document

Overrides:
Source:
Returns:

true in case of a match

Type
boolean

rewriteUrl(url) → {string}

Rewrites an URL.

Parameters:
Name Type Description
url string

the URL to rewrite

Source:
Returns:

the rewritten URL, or the original in case of failure

Type
string

setDisabledForSubscription(subscriptionUrlopt, valueopt)

Disables or enables the filter.

Parameters:
Name Type Attributes Description
subscriptionUrl string <optional>

The subscription on which to disable / enable the filter.

value boolean <optional>

new disabled value, true for disabled and false for enabled

Overrides:
Source: