Class Utils
Defined in: Utils.jsm.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Utils()
Provides a bunch of utility functions.
|
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
Utils.addonBuild
Returns the VCS revision used for this Adblock Plus build
|
| <static> |
Utils.addonID
Returns the add-on ID used by Adblock Plus
|
| <static> |
Utils.addonVersion
Returns the installed Adblock Plus version
|
| <static> |
Utils.appID
Returns ID of the application
|
| <static> |
Utils.appLocale
Returns the user interface locale selected for adblockplus chrome package.
|
| <static> |
Utils.collapsedClass
Randomly generated class for collapsed nodes.
|
| <static> |
Utils.isFennec
Returns whether we are running in Fennec, for Fennec-specific hacks
|
| <static> |
Utils.platformVersion
Returns version of the Gecko platform
|
| <static> |
Utils.scheduledNodes
Nodes scheduled for post-processing (might be null).
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
Utils.alert(parentWindow, message, title)
Shows an alert message like window.alert() but with a custom title.
|
| <static> |
Utils.checkLocalePrefixMatch(prefixes)
Checks whether any of the prefixes listed match the application locale,
returns matching prefix if any.
|
| <static> |
Utils.chooseFilterSubscription(subscriptions)
Chooses the best filter subscription for user's language.
|
| <static> |
Utils.confirm(parentWindow, message, title)
Asks the user for a confirmation like window.confirm() but with a custom title.
|
| <static> |
Utils.formatTime(time)
Formats a unix time according to user's locale.
|
| <static> |
Utils.generateChecksum(lines)
Generates filter subscription checksum.
|
| <static> |
Utils.getOriginWindow(wnd)
If the window doesn't have its own security context (e.g.
|
| <static> |
Utils.getParams()
Retrieves and removes sidebar state after detaching/reattaching
|
| <static> |
Utils.getRequestWindow(channel)
Gets the DOM window associated with a particular request (if any).
|
| <static> |
Utils.getString(name)
Retrieves a string from global.properties string bundle, will throw if string isn't found.
|
| <static> |
Utils.getWindow(node)
Retrieves the window for a document node.
|
| <static> |
Utils.loadDocLink(linkID)
Opens a pre-defined documentation link in the browser window.
|
| <static> |
Utils.loadInBrowser(url, currentWindow, event)
Opens a URL in the browser window.
|
| <static> |
Utils.makeURI(url)
Translates a string URI into its nsIURI representation, will return null for
invalid URIs.
|
| <static> |
Utils.openFiltersDialog(filter)
Opens filter preferences dialog or focuses an already open dialog.
|
| <static> |
Utils.postProcessNodes()
Processes nodes scheduled for post-processing (typically hides them).
|
| <static> |
Utils.runAsync(callback, thisPtr)
Posts an action to the event queue of the current thread to run it
asynchronously.
|
| <static> |
Utils.schedulePostProcess(node)
Schedules a node for post-processing.
|
| <static> |
Utils.setParams(params)
Saves sidebar state before detaching/reattaching
|
| <static> |
Utils.unwrapURL(url)
If a protocol using nested URIs like jar: is used - retrieves innermost
nested URI.
|
| <static> |
Utils.verifySignature(key, signature, data)
Verifies RSA signature.
|
Field Detail
<static>
Utils.addonBuild
Returns the VCS revision used for this Adblock Plus build
<static>
Utils.addonID
Returns the add-on ID used by Adblock Plus
<static>
Utils.addonVersion
Returns the installed Adblock Plus version
<static>
Utils.appID
Returns ID of the application
<static>
Utils.appLocale
Returns the user interface locale selected for adblockplus chrome package.
<static>
{String}
Utils.collapsedClass
Randomly generated class for collapsed nodes.
<static>
{Boolean}
Utils.isFennec
Returns whether we are running in Fennec, for Fennec-specific hacks
<static>
Utils.platformVersion
Returns version of the Gecko platform
<static>
{Array of Node}
Utils.scheduledNodes
Nodes scheduled for post-processing (might be null).
Method Detail
<static>
Utils.alert(parentWindow, message, title)
Shows an alert message like window.alert() but with a custom title.
- Parameters:
- {Window} parentWindow
- parent window of the dialog (can be null)
- {String} message
- message to be displayed
- {String} title Optional
- dialog title, default title will be used if omitted
<static>
{String}
Utils.checkLocalePrefixMatch(prefixes)
Checks whether any of the prefixes listed match the application locale,
returns matching prefix if any.
- Parameters:
- {String} prefixes
<static>
{Node}
Utils.chooseFilterSubscription(subscriptions)
Chooses the best filter subscription for user's language.
- Parameters:
- {NodeList} subscriptions
<static>
{Bool}
Utils.confirm(parentWindow, message, title)
Asks the user for a confirmation like window.confirm() but with a custom title.
- Parameters:
- {Window} parentWindow
- parent window of the dialog (can be null)
- {String} message
- message to be displayed
- {String} title Optional
- dialog title, default title will be used if omitted
- Returns:
- {Bool}
<static>
{String}
Utils.formatTime(time)
Formats a unix time according to user's locale.
- Parameters:
- {Integer} time
- unix time in milliseconds
- Returns:
- {String} formatted date and time
<static>
{String}
Utils.generateChecksum(lines)
Generates filter subscription checksum.
- Parameters:
- {Array of String} lines
- filter subscription lines (with checksum line removed)
- Returns:
- {String} checksum or null
<static>
{Window}
Utils.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:
- {Window} wnd
<static>
Utils.getParams()
Retrieves and removes sidebar state after detaching/reattaching
<static>
{nsIDOMWindow}
Utils.getRequestWindow(channel)
Gets the DOM window associated with a particular request (if any).
- Parameters:
- {nsIChannel} channel
<static>
{String}
Utils.getString(name)
Retrieves a string from global.properties string bundle, will throw if string isn't found.
- Parameters:
- {String} name
- string name
- Returns:
- {String}
<static>
{Window}
Utils.getWindow(node)
Retrieves the window for a document node.
- Parameters:
- {Node} node
- Returns:
- {Window} will be null if the node isn't associated with a window
<static>
Utils.loadDocLink(linkID)
Opens a pre-defined documentation link in the browser window. This will
send the UI language to adblockplus.org so that the correct language
version of the page can be selected.
- Parameters:
- {String} linkID
<static>
Utils.loadInBrowser(url, currentWindow, event)
Opens a URL in the browser window. If browser window isn't passed as parameter,
this function attempts to find a browser window. If an event is passed in
it should be passed in to the browser if possible (will e.g. open a tab in
background depending on modifiers keys).
- Parameters:
- {String} url
- {Window} currentWindow
- {Event} event
<static>
{nsIURI}
Utils.makeURI(url)
Translates a string URI into its nsIURI representation, will return null for
invalid URIs.
- Parameters:
- {String} url
<static>
Utils.openFiltersDialog(filter)
Opens filter preferences dialog or focuses an already open dialog.
- Parameters:
- {Filter} filter Optional
- filter to be selected
<static>
Utils.postProcessNodes()
Processes nodes scheduled for post-processing (typically hides them).
<static>
Utils.runAsync(callback, thisPtr)
Posts an action to the event queue of the current thread to run it
asynchronously. Any additional parameters to this function are passed
as parameters to the callback.
- Parameters:
- {Function} callback
- {Object} thisPtr
<static>
Utils.schedulePostProcess(node)
Schedules a node for post-processing.
- Parameters:
- node
<static>
Utils.setParams(params)
Saves sidebar state before detaching/reattaching
- Parameters:
- params
<static>
{nsIURI}
Utils.unwrapURL(url)
If a protocol using nested URIs like jar: is used - retrieves innermost
nested URI.
- Parameters:
- {nsIURI or String} url
<static>
{Boolean}
Utils.verifySignature(key, signature, data)
Verifies RSA signature. The public key and signature should be base64-encoded.
- Parameters:
- {String} key
- {String} signature
- {String} data