Class: Utils

Utils()

new Utils()

Provides a bunch of utility functions.
Source:

Members

(static) addonID

Returns the add-on ID used by Adblock Plus
Source:

(static) addonVersion

Returns the installed Adblock Plus version
Source:

(static) appLocale

Returns the user interface locale selected for adblockplus chrome package.
Source:

(static) platformVersion

Returns version of the Gecko platform
Source:

Methods

(static) alert(parentWindow, message, titleopt)

Shows an alert message like window.alert() but with a custom title.
Parameters:
Name Type Attributes Description
parentWindow Window parent window of the dialog (can be null)
message String message to be displayed
title String <optional>
dialog title, default title will be used if omitted
Source:

(static) checkLocalePrefixMatch(prefixes)

Checks whether any of the prefixes listed match the application locale, returns matching prefix if any.
Parameters:
Name Type Description
prefixes
Source:

(static) chooseFilterSubscription(subscriptions)

Chooses the best filter subscription for user's language.
Parameters:
Name Type Description
subscriptions
Source:

(static) confirm(parentWindow, message, titleopt) → {Bool}

Asks the user for a confirmation like window.confirm() but with a custom title.
Parameters:
Name Type Attributes Description
parentWindow Window parent window of the dialog (can be null)
message String message to be displayed
title String <optional>
dialog title, default title will be used if omitted
Source:
Returns:
Type
Bool

(static) formatTime(time) → {String}

Formats a unix time according to user's locale.
Parameters:
Name Type Description
time Integer unix time in milliseconds
Source:
Returns:
formatted date and time
Type
String

(static) generateChecksum(lines) → {String}

Generates filter subscription checksum.
Parameters:
Name Type Description
lines Array.<string> filter subscription lines (with checksum line removed)
Source:
Returns:
checksum or null
Type
String

(static) getChromeWindow(window)

Retrieves the top-level chrome window for a content window.
Parameters:
Name Type Description
window
Source:
Returns the documentation link from the preferences.
Parameters:
Name Type Description
linkID
Source:

(static) getOriginWindow(wnd)

If the window doesn't have its own security context (e.g. about:blank or data: URL) walks up the parent chain until a window is found that has a security context.
Parameters:
Name Type Description
wnd
Source:

(static) getParams()

Retrieves and removes sidebar state after detaching/reattaching
Source:

(static) getString(name) → {String}

Retrieves a string from global.properties string bundle, will throw if string isn't found.
Parameters:
Name Type Description
name String string name
Source:
Returns:
Type
String

(static) getWindow(node) → {Window}

Retrieves the window for a document node.
Parameters:
Name Type Description
node
Source:
Returns:
will be null if the node isn't associated with a window
Type
Window

(static) makeURI(url)

Translates a string URI into its nsIURI representation, will return null for invalid URIs.
Parameters:
Name Type Description
url
Source:

(static) runAsync(callback)

Posts an action to the event queue of the current thread to run it asynchronously.
Parameters:
Name Type Description
callback function
Source:

(static) setParams()

Saves sidebar state before detaching/reattaching
Source:

(static) splitAllLabels(root)

Split all labels starting from a particular DOM node.
Parameters:
Name Type Description
root
Source:

(static) splitLabel(label) → {Array}

Splits up a combined label into the label and access key components.
Parameters:
Name Type Description
label
Source:
Returns:
An array with two strings: label and access key
Type
Array

(static) unwrapURL(url)

If a protocol using nested URIs like jar: is used - retrieves innermost nested URI.
Parameters:
Name Type Description
url
Source:

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

Verifies RSA signature. The public key and signature should be base64-encoded.
Parameters:
Name Type Description
key string
signature string
data string
Source:
Returns:
Type
boolean