Module

Module~ Module

Base class for all modules used to support websites.

A module is a content-script executed on a website to replace its custom video player with the browser native HTML5 video player. This class abstract module/backgroun-script messages/options handling. See Adding new website support for detailed steps to add new website support.

Constructor

new Module(namenon-null)

Define module unique name.

Source:
Parameters:
Name Type Description
name string

Module unique name.

Members

messageListeners :Object.<string, Array.<function()>>

Mapping of event and its handlers.

Source:
See:
  • addMessageListener for how to add event listener.
Type:
  • Object.<string, Array.<function()>>

messageListeners :Object.<string, Array.<function()>>

Mapping of event and its handlers.

Source:
See:
  • addMessageListener for how to add event listener.
Type:
  • Object.<string, Array.<function()>>

name :string

The unique name of module.

Source:
Type:
  • string

name :string

The unique name of module.

Source:
Type:
  • string

options :Options

Options instance of this module to get/set extension general options and module special options.

Source:
Type:
  • Options

options :Options

Options instance of this module to get/set extension general options and module special options.

Source:
Type:
  • Options

port :chrome.runtime.Port

The webExtension port to communicate with the background script.

Source:
Type:
  • chrome.runtime.Port

port :chrome.runtime.Port

The webExtension port to communicate with the background script.

Source:
Type:
  • chrome.runtime.Port

Methods

addMessageListener(typenon-null, fnnon-null)

Register a callback function to execute when a message with provided type has been recived from the background script.

Source:
Parameters:
Name Type Description
type string

The type of message to handle.

fn function

The callback function to execute when a message with provided type is recived.

addMessageListener(typenon-null, fnnon-null)

Register a callback function to execute when a message with provided type has been recived from the background script.

Source:
Parameters:
Name Type Description
type string

The type of message to handle.

fn function

The callback function to execute when a message with provided type is recived.

log(…args)

Log a message to the console if debug mode is enabled.

Source:
Parameters:
Name Type Attributes Description
args string <repeatable>

Strings to print on the debug message.

log(…args)

Log a message to the console if debug mode is enabled.

Source:
Parameters:
Name Type Attributes Description
args string <repeatable>

Strings to print on the debug message.

(abstract) onComplete()

Module code to execute after full page is loaded (DOM ready and other resources are loaded)

Source:

(abstract) onComplete()

Module code to execute after full page is loaded (DOM ready and other resources are loaded)

Source:

(abstract) onInteractive()

Module code to execute when DOM tree is ready but other resources are still loading

Source:

(abstract) onInteractive()

Module code to execute when DOM tree is ready but other resources are still loading

Source:

(abstract) onLoading()

Module code to execute when page loading starts (before DOM tree is ready)

Source:

(abstract) onLoading()

Module code to execute when page loading starts (before DOM tree is ready)

Source:

start()

The module routine execution function. It ensures module options has been recived from the background script and execute module functions (onLoading, onInteractive, onComplete). Ensure to call this function at the end of module file the following way:

Source:
Example

A example of starting a website module.

new ChildModuleX().start();

start()

The module routine execution function. It ensures module options has been recived from the background script and execute module functions (onLoading, onInteractive, onComplete). Ensure to call this function at the end of module file the following way:

Source:
Example

A example of starting a website module.

new ChildModuleX().start();

Module~ Module

Base class for all modules used to support websites.

A module is a content-script executed on a website to replace its custom video player with the browser native HTML5 video player. This class abstract module/backgroun-script messages/options handling. See Adding new website support for detailed steps to add new website support.

Constructor

new Module(namenon-null)

Define module unique name.

Source:
Parameters:
Name Type Description
name string

Module unique name.

Members

messageListeners :Object.<string, Array.<function()>>

Mapping of event and its handlers.

Source:
See:
  • addMessageListener for how to add event listener.
Type:
  • Object.<string, Array.<function()>>

messageListeners :Object.<string, Array.<function()>>

Mapping of event and its handlers.

Source:
See:
  • addMessageListener for how to add event listener.
Type:
  • Object.<string, Array.<function()>>

name :string

The unique name of module.

Source:
Type:
  • string

name :string

The unique name of module.

Source:
Type:
  • string

options :Options

Options instance of this module to get/set extension general options and module special options.

Source:
Type:
  • Options

options :Options

Options instance of this module to get/set extension general options and module special options.

Source:
Type:
  • Options

port :chrome.runtime.Port

The webExtension port to communicate with the background script.

Source:
Type:
  • chrome.runtime.Port

port :chrome.runtime.Port

The webExtension port to communicate with the background script.

Source:
Type:
  • chrome.runtime.Port

Methods

addMessageListener(typenon-null, fnnon-null)

Register a callback function to execute when a message with provided type has been recived from the background script.

Source:
Parameters:
Name Type Description
type string

The type of message to handle.

fn function

The callback function to execute when a message with provided type is recived.

addMessageListener(typenon-null, fnnon-null)

Register a callback function to execute when a message with provided type has been recived from the background script.

Source:
Parameters:
Name Type Description
type string

The type of message to handle.

fn function

The callback function to execute when a message with provided type is recived.

log(…args)

Log a message to the console if debug mode is enabled.

Source:
Parameters:
Name Type Attributes Description
args string <repeatable>

Strings to print on the debug message.

log(…args)

Log a message to the console if debug mode is enabled.

Source:
Parameters:
Name Type Attributes Description
args string <repeatable>

Strings to print on the debug message.

(abstract) onComplete()

Module code to execute after full page is loaded (DOM ready and other resources are loaded)

Source:

(abstract) onComplete()

Module code to execute after full page is loaded (DOM ready and other resources are loaded)

Source:

(abstract) onInteractive()

Module code to execute when DOM tree is ready but other resources are still loading

Source:

(abstract) onInteractive()

Module code to execute when DOM tree is ready but other resources are still loading

Source:

(abstract) onLoading()

Module code to execute when page loading starts (before DOM tree is ready)

Source:

(abstract) onLoading()

Module code to execute when page loading starts (before DOM tree is ready)

Source:

start()

The module routine execution function. It ensures module options has been recived from the background script and execute module functions (onLoading, onInteractive, onComplete). Ensure to call this function at the end of module file the following way:

Source:
Example

A example of starting a website module.

new ChildModuleX().start();

start()

The module routine execution function. It ensures module options has been recived from the background script and execute module functions (onLoading, onInteractive, onComplete). Ensure to call this function at the end of module file the following way:

Source:
Example

A example of starting a website module.

new ChildModuleX().start();