new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Electron · API · all subjects

extensions/methods

11 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

extensions.loadExtension method signature

Method signature: extensions.loadExtension(path[, options]). Parameter path is a string for the path to a directory containing an unpacked Chrome extension. Parameter options is an optional Object with property allowFileAccess (boolean, defaults to false) to allow the extension to read local files over file:// protocol and inject content scripts into file:// pages. Returns Promise<Extension> that resolves when the extension is loaded.

extensions.loadExtension behavior and limitations

The loadExtension method raises an exception if the extension cannot be loaded. Warnings when installing the extension are logged to the console. Electron does not support the full range of Chrome extensions APIs. In previous versions, loaded extensions were remembered for future runs, but this is no longer the case: loadExtension must be called on every boot if the extension should be loaded. Packed (.crx) extensions are not supported. This API cannot be called before the app module's ready event is emitted. Loading extensions into in-memory (non-persistent) sessions is not supported and will throw an error.

extensions.loadExtension example with React DevTools

Example code: const { app, session } = require('electron') const path = require('node:path') app.whenReady().then(async () => { await session.defaultSession.extensions.loadExtension( path.join(__dirname, 'react-devtools'), { allowFileAccess: true } ) }) This example shows loading a React DevTools extension from a local directory with allowFileAccess enabled for file:// URLs.

extensions.removeExtension method

Method signature: extensions.removeExtension(extensionId). Parameter extensionId is a string for the ID of the extension to remove. Unloads an extension. This API cannot be called before the app module's ready event is emitted.

extensions.getExtension method

Method signature: extensions.getExtension(extensionId). Parameter extensionId is a string for the ID of the extension to query. Returns Extension | null, the loaded extension with the given ID, or null if not found. This API cannot be called before the app module's ready event is emitted.

extensions.getAllExtensions method

Method signature: extensions.getAllExtensions(). Takes no parameters. Returns Extension[], a list of all loaded extensions. This API cannot be called before the app module's ready event is emitted.

Load extension example code

Example of loading an unpacked extension: ```js const { session } = require('electron') session.defaultSession.loadExtension('path/to/unpacked/extension').then(({ id }) => { // ... }) ```

chrome.extension methods supported

The following methods of chrome.extension are supported in Electron: chrome.extension.getURL, chrome.extension.getBackgroundPage.

chrome.management methods supported

The following methods of chrome.management are supported in Electron: chrome.management.getAll, chrome.management.get, chrome.management.getSelf, chrome.management.getPermissionWarningsById, chrome.management.getPermissionWarningsByManifest.

chrome.runtime methods supported

The following methods of chrome.runtime are supported in Electron: chrome.runtime.getBackgroundPage, chrome.runtime.getManifest, chrome.runtime.getPlatformInfo, chrome.runtime.getURL, chrome.runtime.connect, chrome.runtime.sendMessage, chrome.runtime.reload.

chrome.tabs methods supported

The following methods of chrome.tabs are supported in Electron: chrome.tabs.sendMessage, chrome.tabs.reload, chrome.tabs.executeScript, chrome.tabs.query (partial support), chrome.tabs.update (partial support).

Give your agent this brain