Global

Members

(constant) allKeywordsRegExp :RegExp

Regular expression for matching all keywords in a filter.
Type:
  • RegExp
Source:

body :string

The body of the filter
Type:
  • string
Source:

(nullable) commonStyleSheet :string

The common style sheet that applies on all unknown domains. This is a concatenation of the default style sheet and an additional style sheet based on selectors from all generic filters that are not in the unconditionalSelectors list.
Type:
  • string
Source:

(constant) COMPILE_PATTERNS_MAX :number

The maximum number of patterns that compilePatterns will compile into regular expressions.
Type:
  • number
Source:

contentType :number

Content types the filter applies to, combination of values from RegExpFilter.typeMap
Type:
  • number
Source:

(nullable) csp :string

Content Security Policy to inject for matching requests.
Type:
  • string
Source:

(constant) DEFAULT_TYPES :number

Bitmask for content types that are implied by default in a filter, like $script, $image, $stylesheet, and so on.
Type:
  • number
Source:

defaultDomains :Map.<string, boolean>

Map to be used instead when a filter has a blank domains property.
Type:
  • Map.<string, boolean>
Source:

defaultMatcher :CombinedMatcher

Shared CombinedMatcher instance that should usually be used.
Type:
Source:

defaults :Array.<string>

Filter types that should be added to this subscription by default (entries should correspond to keys in SpecialSubscription.defaultsMap).
Type:
  • Array.<string>
Source:

(nullable) defaultStyleSheet :string

The default style sheet that applies on all domains. This is based on the value of unconditionalSelectors.
Type:
  • string
Source:

disabled :boolean

Defines whether the filter is disabled
Type:
  • boolean
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>
Source:

domainsCache :Map.<string, Map.<string, boolean>>

Cache of domain maps. The domains part of filter text (e.g. example.com,~mail.example.com) is often repeated across filters. This cache enables deduplication of the Map objects that specify on which domains the filter does and does not apply, which reduces memory usage and improves performance.
Type:
  • Map.<string, Map.<string, boolean>>
Source:

domainSeparator :string

Separator character used in domainSource property, must be overridden by subclasses
Type:
  • string
Source:

domainSeparator

Source:
See:
  • ActiveFilter.domainSeparator

domainSeparator

Source:
See:
  • ActiveFilter.domainSeparator

(nullable) domainSource :string

String that the domains property should be generated from
Type:
  • string
Source:

doubleAnchorRegExp :RegExp

Regular expression used to match the || prefix in an otherwise literal pattern.
Type:
  • RegExp
Source:

downloadCount :number

Number indicating how often the object was downloaded.
Type:
  • number
Source:

downloader :Downloader

The object providing actual downloading functionality.
Type:
Source:

downloadStatus :string

Status of the last download (ID of a string)
Type:
  • string
Source:

errors :number

Number of download failures since last success
Type:
  • number
Source:

exceptions :Map.<string, Array.<ElemHideException>>

Lookup table, lists of element hiding exceptions by selector
Type:
Source:

expires :number

Hard expiration time of the filter subscription (in seconds since the beginning of the epoch)
Type:
  • number
Source:

filterBySelector :Map.<string, Filter>

Lookup table, filter by selector. (Only used for selectors that are unconditionally matched for all domains.)
Type:
Source:

filterNotifier :EventEmitter

This object allows registering and triggering listeners for filter events.
Type:
Source:

filtersByDomain :FiltersByDomain

Lookup table, active flag, by filter by domain. (Only contains filters that aren't unconditionally matched for all domains.)
Type:
Source:

filterStorage

Reads the user's filters from disk, manages them in memory, and writes them back to disk.
Source:

(constant) FORMAT_VERSION :number

Version number of the filter storage file format.
Type:
  • number
Source:

hitCount :number

Number of hits on the filter since the last reset
Type:
  • number
Source:

homepage :string

Filter subscription homepage if known
Type:
  • string
Source:

isDirty :number

Increases on filter changes, filters will be saved if it exceeds 1.
Type:
  • number
Source:

(constant) keywordRegExp :RegExp

Regular expression for matching a keyword in a filter.
Type:
  • RegExp
Source:

knownExceptionDomains :Set.<string>

All domains known to occur in exceptions
Type:
  • Set.<string>
Source:

knownExceptions :Set.<ElemHideException>

Set containing known element exceptions
Type:
Source:

knownFilters :Set.<ElemHideFilter>

Set containing known element hiding filters
Type:
Source:

lastCheck :number

Time when the subscription was considered for an update last time (in seconds since the beginning of the epoch). This will be used to increase softExpiration if the user doesn't use Adblock Plus for some time.
Type:
  • number
Source:

lastDownload :number

Time of the last subscription download (in seconds since the beginning of the epoch)
Type:
  • number
Source:

lastHit :number

Last time the filter had a hit (in milliseconds since the beginning of the epoch)
Type:
  • number
Source:

lastSuccess

Time of the last successful download (in seconds since the beginning of the epoch).
Source:

matchCase :boolean

Defines whether the filter should distinguish between lower and upper case letters
Type:
  • boolean
Source:

(constant) NON_DEFAULT_TYPES :number

Bitmask for "types" that must always be specified in a filter explicitly, like $csp, $popup, $elemhide, and so on.
Type:
  • number
Source:

(nullable) pattern :string

Expression from which a regular expression should be generated - for delayed creation of the regexp property
Type:
  • string
Source:

publicSuffixMap :Map.<string, number>

Map of public suffixes to their offsets.
Type:
  • Map.<string, number>
Source:

reason :string

Reason why this filter is invalid
Type:
  • string
Source:

regexp :RegExp

Regular expression to be used when testing against this filter
Type:
  • RegExp
Source:

requiredVersion :string

Minimal Adblock Plus version required for this subscription
Type:
  • string
Source:

resourceMap :Map.<string, string>

Map of internal resources for URL rewriting.
Type:
  • Map.<string, string>
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
Source:

script :string

Script that should be executed
Type:
  • string
Source:

selector :string

CSS selector for the HTML elements that should be hidden
Type:
  • string
Source:

(constant) selectorGroupSize :number

The maximum number of selectors in a CSS rule. This is used by createStyleSheet to split up a long list of selectors into multiple rules.
Type:
  • number
Default Value:
  • 1024
Source:

separatorRegExp :RegExp

Regular expression used to match the ^ suffix in an otherwise literal pattern.
Type:
  • RegExp
Source:

sitekeys

Source:
See:
  • ActiveFilter.sitekeys

(nullable) sitekeys :Array.<string>

Array containing public keys of websites that this filter should apply to
Type:
  • Array.<string>
Source:

(nullable) sitekeySource :string

String that the sitekey property should be generated from
Type:
  • string
Source:

(package) size :number

Number of filters contained, will always be 1 (required to optimize Matcher).
Type:
  • number
Source:

snippets :Snippets

Container for snippet filters.
Type:
Source:

softExpiration :number

Soft expiration time of the filter subscription (in seconds since the beginning of the epoch)
Type:
  • number
Source:

styleSheetCache :Cache.<string, string>

Cache of generated domain-specific style sheets. This contains entries for only known domains. If a domain is unknown, it gets commonStyleSheet.
Type:
Source:

synchronizer :Synchronizer

This object is responsible for downloading filter subscriptions whenever necessary.
Type:
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
Source:

typesByURL :Map.<string, string>

Subscription types by URL.
Type:
  • Map.<string, string>
Source:

(nullable) unconditionalSelectors :Array.<string>

This array caches the keys of filterBySelector table (selectors which unconditionally apply on all domains). It will be null if the cache needs to be rebuilt.
Type:
  • Array.<string>
Source:

version :number

Version of the subscription data retrieved on last successful download
Type:
  • number
Source:

(constant) WHITELIST_ONLY_TYPES :number

Bitmask for "types" that are for exception rules only, like $document, $elemhide, and so on.
Type:
  • number
Source:

Methods

add(exception)

Add a new element hiding exception
Parameters:
Name Type Description
exception ElemHideException
Source:

addFilter(filter, subscriptionsopt, nullable)

Notifies Matcher instances or ElemHide object about a new filter if necessary.
Parameters:
Name Type Attributes Default Description
filter Filter filter that has been added
subscriptions Array.<Subscription> <optional>
<nullable>
null subscriptions to which the filter belongs
Source:

addFilterByKeyword(filter, keyword, map)

Adds a filter by a given keyword to a map.
Parameters:
Name Type Description
filter RegExpFilter
keyword string
map Map.<string, (RegExpFilter|Set.<RegExpFilter>)>
Source:

buildPublicSuffixMap() → {Map.<string, number>}

Builds a map of public suffixes to their offsets.
Source:
Returns:
Type
Map.<string, number>

clear()

Removes all known exceptions
Source:

(package) compareVersions(v1, v2) → {number}

Compares two versions.
Parameters:
Name Type Description
v1 string The first version.
v2 string The second version.
Source:
Returns:
-1 if v1 is older than v2; 1 if v1 is newer than v2; otherwise 0.
Type
number

compilePatterns(filters) → (nullable) {CompiledPatterns}

Compiles patterns from the given filters into a single CompiledPatterns object.
Parameters:
Name Type Description
filters RegExpFilter | Set.<RegExpFilter> The filters. If the number of filters exceeds COMPILE_PATTERNS_MAX, the function returns null.
Source:
Returns:
Type
CompiledPatterns

compileScript(script, libraries) → {string}

Compiles a script against a given list of libraries into executable code.
Parameters:
Name Type Description
script string
libraries Array.<string>
Source:
Returns:
Type
string

createRule(selectors) → {string}

Creates an element hiding CSS rule for a given list of selectors.
Parameters:
Name Type Description
selectors Array.<string>
Source:
Returns:
Type
string

createStyleSheet(selectors) → {string}

Creates an element hiding CSS style sheet from a given list of selectors.
Parameters:
Name Type Description
selectors Array.<string>
Source:
Returns:
Type
string

(generator) domainSuffixes(domain, includeBlankopt) → {string}

Yields all suffixes for a domain. For example, given the domain www.example.com, this function yields www.example.com, example.com, and com, in that order.
Parameters:
Name Type Attributes Default Description
domain string The domain.
includeBlank boolean <optional>
false Whether to include the blank suffix at the end.
Source:
Yields:
The next suffix for the domain.
Type
string

(package) entries() → {Array}

Yields a key-value pair consisting of the filter itself and the value true (required to optimize Matcher).
Source:
Yields:
Type
Array

escapeSelector(selector) → {string}

Escapes curly braces to prevent CSS rule injection.
Parameters:
Name Type Description
selector string
Source:
Returns:
Type
string

filterToRegExp(text, captureAllopt) → {string}

Converts filter text into regular expression string
Parameters:
Name Type Attributes Default Description
text string as in Filter()
captureAll boolean <optional>
false whether to enable the capturing of leading and trailing wildcards in the filter text; by default, leading and trailing wildcards are stripped out
Source:
Returns:
regular expression representation of filter text
Type
string

getBaseDomain(hostname) → {string}

Gets the base domain for the given hostname.
Parameters:
Name Type Description
hostname string
Source:
Returns:
Type
string

getCommonStyleSheet() → {string}

Returns the common style sheet that applies on all unknown domains.
Source:
Returns:
Type
string

getConditionalSelectors(domain, specificOnly) → {Array.<string>}

Returns the list of selectors that apply on a given domain from the subset of filters that do not apply unconditionally on all domains.
Parameters:
Name Type Description
domain string The domain.
specificOnly boolean Whether selectors from generic filters should be included.
Source:
Returns:
The list of selectors.
Type
Array.<string>

getConditionalSelectorsWithExceptions(domain, specificOnly) → {Object}

Returns the list of selectors and the list of exceptions that apply on a given domain from the subset of filters that do not apply unconditionally on all domains.
Parameters:
Name Type Description
domain string The domain.
specificOnly boolean Whether selectors from generic filters should be included.
Source:
Returns:
An object containing the lists of selectors and exceptions.
Type
Object

getDefaultStyleSheet() → {string}

Returns the default style sheet that applies on all domains.
Source:
Returns:
Type
string

getDomainSpecificStyleSheet(domain) → {string}

Returns the domain-specific style sheet that applies on a given domain.
Parameters:
Name Type Description
domain string
Source:
Returns:
Type
string

getException(selector, docDomainnullable) → (nullable) {ElemHideException}

Checks whether an exception rule is registered for a selector on a particular domain.
Parameters:
Name Type Attributes Description
selector string
docDomain string <nullable>
Source:
Returns:
Type
ElemHideException

getKnownSuffix(domainnullable) → {string}

Returns the suffix of the given domain that is known. If no suffix is known, an empty string is returned.
Parameters:
Name Type Attributes Description
domain string <nullable>
Source:
Returns:
Type
string

getUnconditionalSelectors() → {Array.<string>}

Returns a list of selectors that apply on each website unconditionally.
Source:
Returns:
Type
Array.<string>

hasExceptions(selector) → {boolean}

Checks whether any exception rules are registered for a selector
Parameters:
Name Type Description
selector string
Source:
Returns:
Type
boolean

init()

Initializes filter listener on startup, registers the necessary hooks.
Source:

isActiveOnDomain(docDomainopt, sitekeyopt) → {boolean}

Checks whether this filter is active on a domain.
Parameters:
Name Type Attributes Description
docDomain string <optional>
domain name of the document that loads the URL
sitekey string <optional>
public key provided by the document
Source:
Returns:
true in case of the filter being active
Type
boolean

isActiveOnlyOnDomain(docDomain) → {boolean}

Checks whether this filter is active only on a domain and its subdomains.
Parameters:
Name Type Description
docDomain string
Source:
Returns:
Type
boolean

isDefaultFor(filter) → {boolean}

Tests whether a filter should be added to this group by default
Parameters:
Name Type Description
filter Filter filter to be tested
Source:
Returns:
Type
boolean

isGeneric() → {boolean}

Checks whether this filter is generic or specific
Source:
Returns:
Type
boolean

isIPAddress(hostname) → {boolean}

Checks whether the given hostname is an IP address.
Parameters:
Name Type Description
hostname string
Source:
Returns:
Type
boolean

isLiteralPattern(pattern) → {boolean}

Checks whether the given pattern is a string of literal characters with no wildcards or any other special characters. If the pattern is prefixed with a || or suffixed with a ^ but otherwise contains no special characters, it is still considered to be a literal pattern.
Parameters:
Name Type Description
pattern string
Source:
Returns:
Type
boolean

isLocationOnly() → {boolean}

Checks whether this filter has only a URL pattern and no content type, third-party flag, domains, or sitekeys.
Source:
Returns:
Type
boolean

isSlowFilter(filter) → {boolean}

Checks whether a particular filter is slow.
Parameters:
Name Type Description
filter RegExpFilter
Source:
Returns:
Type
boolean

isThirdParty(requestHostname, documentHostname) → {boolean}

Checks whether a request's origin is different from its document's origin.
Parameters:
Name Type Description
requestHostname string The IDNA-encoded hostname of the request.
documentHostname string The IDNA-encoded hostname of the document.
Source:
Returns:
Type
boolean

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

Tests whether the URL request matches this filter
Parameters:
Name Type Attributes Description
request URLRequest URL request to be tested
typeMask number bitmask of content / request types to match
sitekey string <optional>
public key provided by the document
Source:
Returns:
true in case of a match
Type
boolean

(package) matchesLocation(request) → {boolean}

Checks whether the given URL request matches this filter's pattern.
Parameters:
Name Type Description
request URLRequest The URL request to check.
Source:
Returns:
true if the URL request matches.
Type
boolean

(package) matchesWithoutDomain(request, typeMask, sitekeyopt) → {boolean}

Checks whether the given URL request matches this filter without checking the filter's domains.
Parameters:
Name Type Attributes Description
request URLRequest
typeMask number
sitekey string <optional>
Source:
Returns:
Type
boolean

(generator) nonDefaultTypes(contentType) → {number}

Yields individual non-default types from a filter's type mask.
Parameters:
Name Type Description
contentType number A filter's type mask.
Source:
Yields:
Type
number

normalizeHostname(hostname) → {string}

Normalizes a hostname.
Parameters:
Name Type Description
hostname string
Source:
Returns:
Type
string

parseDomains(source, separator) → (nullable) {Map.<string, boolean>}

Parses the domains part of a filter text (e.g. example.com,~mail.example.com) into a Map object.
Parameters:
Name Type Description
source string The domains part of a filter text.
separator string The string used to separate two or more domains in the domains part of a filter text.
Source:
Returns:
Type
Map.<string, boolean>

parseScript(script) → {Array.<Array.<string>>}

Parses a script and returns a list of all its commands and their arguments.
Parameters:
Name Type Description
script string
Source:
Returns:
Type
Array.<Array.<string>>

parseURL(url) → {URLInfo}

Parses a URL to extract the protocol and the hostname. This is a lightweight alternative to the native URL object. Unlike the URL object, this function is not robust and will give incorrect results for invalid URLs. Use this function with valid, normalized, properly encoded (IDNA and percent-encoding) URLs only.
Parameters:
Name Type Description
url string The URL to parse.
Source:
Returns:
Information about the URL.
Type
URLInfo

qualifySelector(selector, qualifier) → {string}

Qualifies a CSS selector with a qualifier, which may be another CSS selector or an empty string. For example, given the selector "div.bar" and the qualifier "#foo", this function returns "div#foo.bar".
Parameters:
Name Type Description
selector string The selector to qualify.
qualifier string The qualifier with which to qualify the selector.
Source:
Returns:
The qualified selector.
Type
string

readASN1(data, templ) → {Object}

Reads ASN.1 data matching the template passed in. This will throw an exception if the data format doesn't match the template. On success an object containing result properties is returned.
Parameters:
Name Type Description
data string
templ Object
Source:
See:
Returns:
Type
Object

readPublicKey(key) → (nullable) {Object}

Reads a BER-encoded RSA public key. On success returns an object with the properties n and e (the components of the key), otherwise null.
Parameters:
Name Type Description
key string
Source:
Returns:
Type
Object

(generator) recommendations() → {Recommendation}

Yields Recommendation objects representing recommended filter subscriptions.
Source:
Yields:
An object representing a recommended filter subscription.
Type
Recommendation

remove(exception)

Removes an element hiding exception
Parameters:
Name Type Description
exception ElemHideException
Source:

removeFilter(filter)

Notifies Matcher instances or ElemHide object about removal of a filter if necessary.
Parameters:
Name Type Description
filter Filter filter that has been removed
Source:

removeFilterByKeyword(filter, keyword, map)

Removes a filter by a given keyword from a map.
Parameters:
Name Type Description
filter RegExpFilter
keyword string
map Map.<string, (RegExpFilter|Set.<RegExpFilter>)>
Source:

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

(generator) rulesFromStyleSheet(styleSheet) → {string}

Yields rules from a style sheet returned by createStyleSheet.
Parameters:
Name Type Description
styleSheet string A style sheet returned by createStyleSheet. If the given style sheet is not a value previously returned by a call to createStyleSheet, the behavior is undefined.
Source:
Yields:
A rule from the given style sheet.
Type
string

serialize()

See Filter.serialize()
Source:

serialize()

See Subscription.serialize()
Source:

serialize()

See Filter.serialize()
Source:

serialize()

See Filter.serialize()
Source:

serialize()

See Subscription.serialize()
Source:

serialize()

See Subscription.serialize()
Source:

serialize()

See Subscription.serialize()
Source:

(generator) splitSelectors(selectors) → {Array.<string>}

Splits a list of selectors into groups determined by the value of selectorGroupSize.
Parameters:
Name Type Description
selectors Array.<string>
Source:
Yields:
Type
Array.<string>

stripFirstVersion(firstVersion, currentVersionopt) → (nullable) {string}

Strips the value of the firstVersion parameter down to either YYYYMMDD, YYYYMM, or YYYY depending on its distance from the value of the currentVersion parameter.
Parameters:
Name Type Attributes Default Description
firstVersion string A version string in YYYYMMDD[HH[MM]] format with an optional "-E" suffix or just "0" or "0-E".
currentVersion string <optional>
0 A version string in YYYYMMDD[HH[MM]] format or just "0".
Source:
Returns:
Type
string

textToRegExp(text) → {string}

Converts raw text into a regular expression string
Parameters:
Name Type Description
text string the string to convert
Source:
Returns:
regular expression representation of the text
Type
string

verifySignature(key, signature, data) → {boolean}

Checks whether the signature is valid for the given public key and data.
Parameters:
Name Type Description
key string
signature string
data string
Source:
Returns:
Type
boolean

versionToDate(version) → {Date}

Converts a version string into a Date object with minute-level precision.
Parameters:
Name Type Description
version string The version string in YYYYMMDD[HH[MM]] format or just the value "0".
Source:
Returns:
A Date object. If the value of version is "0", the returned value represents the Unix epoch.
Type
Date

Type Definitions

ElemHideStyleSheet

Type:
  • object
Properties:
Name Type Description
code string CSS code.
selectors Array.<string> List of selectors.
Source:

FileInfo

Type:
  • object
Properties:
Name Type Description
index number
lastModified number
Source:

MatcherSearchResults

Type:
  • object
Properties:
Name Type Attributes Description
blocking Array.<BlockingFilter> <optional>
List of blocking filters found.
whitelist Array.<WhitelistFilter> <optional>
List of whitelist filters found.
Source:

QuestionListener(approved)

A callback function which listens to see if notifications were approved.
Parameters:
Name Type Description
approved boolean
Source:

TextSink(linenullable)

Parameters:
Name Type Attributes Description
line string <nullable>
Source: