2020-02-06 21:36:02 +00:00
|
|
|
# Chrome Extension Support
|
|
|
|
|
|
|
|
Electron supports a subset of the [Chrome Extensions
|
|
|
|
API][chrome-extensions-api-index], primarily to support DevTools extensions and
|
|
|
|
Chromium-internal extensions, but it also happens to support some other
|
|
|
|
extension capabilities.
|
|
|
|
|
|
|
|
[chrome-extensions-api-index]: https://developer.chrome.com/extensions/api_index
|
|
|
|
|
|
|
|
> **Note:** Electron does not support arbitrary Chrome extensions from the
|
|
|
|
> store, and it is a **non-goal** of the Electron project to be perfectly
|
|
|
|
> compatible with Chrome's implementation of Extensions.
|
|
|
|
|
|
|
|
## Loading extensions
|
|
|
|
|
|
|
|
Electron only supports loading unpacked extensions (i.e., `.crx` files do not
|
|
|
|
work). Extensions are installed per-`session`. To load an extension, call
|
2021-02-01 22:41:08 +00:00
|
|
|
[`ses.loadExtension`](session.md#sesloadextensionpath-options):
|
2020-02-06 21:36:02 +00:00
|
|
|
|
|
|
|
```js
|
|
|
|
const { session } = require('electron')
|
|
|
|
|
2022-11-30 19:29:02 +00:00
|
|
|
session.defaultSession.loadExtension('path/to/unpacked/extension').then(({ id }) => {
|
2020-02-06 21:36:02 +00:00
|
|
|
// ...
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
Loaded extensions will not be automatically remembered across exits; if you do
|
|
|
|
not call `loadExtension` when the app runs, the extension will not be loaded.
|
|
|
|
|
2020-02-10 16:28:03 +00:00
|
|
|
Note that loading extensions is only supported in persistent sessions.
|
|
|
|
Attempting to load an extension into an in-memory session will throw an error.
|
|
|
|
|
2020-02-06 21:36:02 +00:00
|
|
|
See the [`session`](session.md) documentation for more information about
|
|
|
|
loading, unloading, and querying active extensions.
|
|
|
|
|
|
|
|
## Supported Extensions APIs
|
|
|
|
|
|
|
|
We support the following extensions APIs, with some caveats. Other APIs may
|
|
|
|
additionally be supported, but support for any APIs not listed here is
|
|
|
|
provisional and may be removed.
|
|
|
|
|
|
|
|
### `chrome.devtools.inspectedWindow`
|
|
|
|
|
|
|
|
All features of this API are supported.
|
|
|
|
|
|
|
|
### `chrome.devtools.network`
|
|
|
|
|
|
|
|
All features of this API are supported.
|
|
|
|
|
|
|
|
### `chrome.devtools.panels`
|
|
|
|
|
|
|
|
All features of this API are supported.
|
|
|
|
|
|
|
|
### `chrome.extension`
|
|
|
|
|
|
|
|
The following properties of `chrome.extension` are supported:
|
|
|
|
|
|
|
|
- `chrome.extension.lastError`
|
|
|
|
|
|
|
|
The following methods of `chrome.extension` are supported:
|
|
|
|
|
|
|
|
- `chrome.extension.getURL`
|
|
|
|
- `chrome.extension.getBackgroundPage`
|
|
|
|
|
|
|
|
### `chrome.runtime`
|
|
|
|
|
|
|
|
The following properties of `chrome.runtime` are supported:
|
|
|
|
|
|
|
|
- `chrome.runtime.lastError`
|
|
|
|
- `chrome.runtime.id`
|
|
|
|
|
|
|
|
The following methods of `chrome.runtime` are supported:
|
|
|
|
|
|
|
|
- `chrome.runtime.getBackgroundPage`
|
|
|
|
- `chrome.runtime.getManifest`
|
2020-09-15 16:29:32 +00:00
|
|
|
- `chrome.runtime.getPlatformInfo`
|
2020-02-06 21:36:02 +00:00
|
|
|
- `chrome.runtime.getURL`
|
|
|
|
- `chrome.runtime.connect`
|
|
|
|
- `chrome.runtime.sendMessage`
|
2021-07-14 22:37:53 +00:00
|
|
|
- `chrome.runtime.reload`
|
2020-02-06 21:36:02 +00:00
|
|
|
|
|
|
|
The following events of `chrome.runtime` are supported:
|
|
|
|
|
|
|
|
- `chrome.runtime.onStartup`
|
|
|
|
- `chrome.runtime.onInstalled`
|
|
|
|
- `chrome.runtime.onSuspend`
|
|
|
|
- `chrome.runtime.onSuspendCanceled`
|
|
|
|
- `chrome.runtime.onConnect`
|
|
|
|
- `chrome.runtime.onMessage`
|
|
|
|
|
|
|
|
### `chrome.storage`
|
|
|
|
|
2023-08-09 12:47:19 +00:00
|
|
|
The following methods of `chrome.storage` are supported:
|
|
|
|
|
|
|
|
- `chrome.storage.local`
|
2020-02-06 21:36:02 +00:00
|
|
|
|
|
|
|
### `chrome.tabs`
|
|
|
|
|
|
|
|
The following methods of `chrome.tabs` are supported:
|
|
|
|
|
|
|
|
- `chrome.tabs.sendMessage`
|
2022-04-11 20:51:10 +00:00
|
|
|
- `chrome.tabs.reload`
|
2020-02-06 21:36:02 +00:00
|
|
|
- `chrome.tabs.executeScript`
|
2023-08-09 12:47:19 +00:00
|
|
|
- `chrome.tabs.query` (partial support)
|
|
|
|
- supported properties: `url`, `title`, `audible`, `active`, `muted`.
|
2021-07-27 20:36:22 +00:00
|
|
|
- `chrome.tabs.update` (partial support)
|
|
|
|
- supported properties: `url`, `muted`.
|
2020-02-06 21:36:02 +00:00
|
|
|
|
|
|
|
> **Note:** In Chrome, passing `-1` as a tab ID signifies the "currently active
|
|
|
|
> tab". Since Electron has no such concept, passing `-1` as a tab ID is not
|
|
|
|
> supported and will raise an error.
|
2020-09-02 00:59:56 +00:00
|
|
|
|
|
|
|
### `chrome.management`
|
|
|
|
|
|
|
|
The following methods of `chrome.management` are supported:
|
|
|
|
|
|
|
|
- `chrome.management.getAll`
|
|
|
|
- `chrome.management.get`
|
|
|
|
- `chrome.management.getSelf`
|
|
|
|
- `chrome.management.getPermissionWarningsById`
|
|
|
|
- `chrome.management.getPermissionWarningsByManifest`
|
2023-08-09 12:47:19 +00:00
|
|
|
|
|
|
|
The following events of `chrome.management` are supported:
|
|
|
|
|
2020-09-02 00:59:56 +00:00
|
|
|
- `chrome.management.onEnabled`
|
|
|
|
- `chrome.management.onDisabled`
|
2020-12-18 23:11:43 +00:00
|
|
|
|
|
|
|
### `chrome.webRequest`
|
|
|
|
|
|
|
|
All features of this API are supported.
|
|
|
|
|
|
|
|
> **NOTE:** Electron's [`webRequest`](web-request.md) module takes precedence over `chrome.webRequest` if there are conflicting handlers.
|