2.0.0 • Published 2 years ago

cordova-plugin-electron-events v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

cordova-plugin-electron-events

A cordova plugin for the electron platform to hook into electron lifecycle events.

Supports listening to events emitted by app object without having to edit electron platform files.

Features

Supported events: https://www.electronjs.org/docs/latest/api/app#events (Check according to the version of electronjs used in your project)

Requires cordova-electron >= 2.0.0.

Installation

$ npm install cordova-plugin-electron-events

Usage

Create a settings.json file in the project for electron (as described here) with additional parameter electronEvents:

"electronEvents": [
  {
    "event": "<event-name>",
    "script": "<src/to/script.js>" // Relative to project root
  }
]

Example:

{
  "browserWindow": {
    "width": 1280,
    "height": 800
  },
  "electronEvents": [
    {
      "event": "web-contents-created",
      "script": "scripts/web-contents-created.js"
    }
  ]
}

Each script should contain a default exported javascript function that matches the signature of the respective electron event handler.

For instance, to modify the user agent of the BrowserWindow instance, the script may look like:

module.exports = function (event, webContents) {
  // Set custom user agent.
  webContents.setUserAgent("Custom User Agent v1.4.7");
};

Issues

Create a GitHub issue.