{"id":13686094,"url":"https://github.com/getstation/electron-chrome-extension","last_synced_at":"2025-05-13T23:32:37.326Z","repository":{"id":36421751,"uuid":"98665631","full_name":"getstation/electron-chrome-extension","owner":"getstation","description":"Implementation of Chrome extension APIs for Electron","archived":false,"fork":false,"pushed_at":"2023-02-03T03:38:05.000Z","size":1153,"stargazers_count":140,"open_issues_count":27,"forks_count":26,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-12T08:35:22.688Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/getstation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-07-28T16:01:07.000Z","updated_at":"2024-09-15T00:14:43.000Z","dependencies_parsed_at":"2024-01-02T21:20:08.490Z","dependency_job_id":"ca30a424-dfbc-40cc-898f-081d79ee0a73","html_url":"https://github.com/getstation/electron-chrome-extension","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getstation%2Felectron-chrome-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getstation%2Felectron-chrome-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getstation%2Felectron-chrome-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getstation%2Felectron-chrome-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getstation","download_url":"https://codeload.github.com/getstation/electron-chrome-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225266529,"owners_count":17446999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T14:01:05.511Z","updated_at":"2024-11-18T23:24:00.645Z","avatar_url":"https://github.com/getstation.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Library","Tools"],"sub_categories":["Uncategorized","For Electron"],"readme":"# Electron Chrome Extension\n\n[![Build Status](https://travis-ci.com/getstation/electron-chrome-extension.svg?token=NLebjoCo6B1MogiwMcNq\u0026branch=master)](https://travis-ci.com/getstation/electron-chrome-extension)\n\n## Environment\nTested with `Electron v4.0.4` - `Node v8.9.0` - `NPM v5.5.1`\n\n## Setup\n\n- **Renderer - preload**\n\n```ts\nrequire('electron-chrome-extension/preload');\n```\n\n*For some reasons the navigator user agent is not inherited from the session so you will need\nto redefine the user agent via the `Object.defineProperty` method after the import*\n\n- **Main**\n\n```ts\nimport ECx from 'electron-chrome-extension';\n\napp.on('ready', async () =\u003e {\n  createWindow();\n\n  // Load Grammarly\n  await ECx.load('kbfnbcaeplbcioakkpcpgfkobkghlhen');\n});\n```\n\n### Connect your application logic\n\nExtensions react to browser events for trigger their own logic.\nECx send inner webContents events to extensions subscribers but external events\nlike creating new window, changing tab focus etc should be triggered on your side like this:\n\n```js\n// main.js\n\nipcMain.on('YOUR_EVENT', (...) =\u003e\n  ECx.sendEvent({\n    channel: 'tabs.onActivated',\n    payload: [{ tabId, windowId }],\n  })\n);\n```\n\n### Usage with DevTools extension\n\n⚠️ `electron-chrome-extension` will break [Electron's support for Devtools extensions](https://electronjs.org/docs/tutorial/devtools-extension).\n\nIf you wish to use devtools extensions, make sure to add the prelaod on the `Session` itself:\n```js\nif (isDev) {\n  app.on('session-created', session =\u003e {\n    session.setPreloads([path.join(__dirname, 'node_modules/electron-chrome-extension/preload')]\n  });\n}\n```\nIt is not recommended to have the preload added to `Sessions` outside developement environnement because it can lead to have extension's code run in priviledged contexts (`BrowserWindows` with `nodeIntegration` for instance).\n\nThen install Chrome DevTools extensions with `electron-chrome-extension`:\n\n```js\nimport ECx from 'electron-chrome-extension';\n// load React Dev Tools\nECx.load('jdkknkkbebbapilgoeccciglkfbmbnfm');\n\n```\n\n## ECx APIs\n\n- `ECx.load(extensionId: IExtension['id']): Promise\u003cIExtension\u003e`\n- `ECx.unload(extensionId: IExtension['id']): void`\n- `ECx.setConfiguration(configuration: Configuration = {}): Promise\u003cECx\u003e`\n- `ECx.isLoaded(extensionId: IExtension['id']): boolean`\n- `ECx.isUpToDate(extensionId: IExtension['id']): Promise\u003cboolean\u003e`\n- `ECx.get(extensionId: IExtension['id']): Promise\u003cIExtension\u003e`\n- `ECx.sendEvent(event: ExtensionEventMessage): void`\n\n## Tools\n\n- Start Playground\n```sh\n$ npm start\n```\n\nYou can tweak the playground files at your convenience and extensions would automatically downloaded and clean app data with `$ npm run playground:reset`\n\n- Test\n```sh\n$ npm test\n```\n\nWe use [electron-mocha](https://github.com/jprichardson/electron-mocha) for run our test suit.\nWarning (because not explained in the lib): test assertions lives in the renderer,\nthe main remains accessible for IPC calls and Electron Main API calls.\n\n- Publish\n```sh\n$ npm publish\n```\n\n## References\n\n- [Chrome Extensions Overview](https://developer.chrome.com/extensions/overview)\n- [Chrome Extensions API index](https://developer.chrome.com/extensions/api_index)\n- [Station Exploration](https://www.notion.so/stationhq/Chrome-Extensions-c964f683125f4a758490b60b5d8e28be)\n\n## Know supported extensions\n\n*as of 05/29/19 with their Chrome WebStore ID*\n\n- Mixmax: ocpljaamllnldhepankaeljmeeeghnid\n- Gmelius: dheionainndbbpoacpnopgmnihkcmnkl\n- Mailtracker: pgbdljpkijehgoacbjpolaomhkoffhnl\n- Boomerang: mdanidgdpmkimeiiojknlnekblgmpdll\n- Clearbit Connect: pmnhcgfcafcnkbengdcanjablaabjplo\n- Grammarly: kbfnbcaeplbcioakkpcpgfkobkghlhen\n- React Developers Tools: fmkadmapgofadopljbjfkapdkoienihi\n- Redux DevTools: lmhkpmbekcpmknklioeibfkpmmfibljd\n- Apollo Client Developer Tools: jdkknkkbebbapilgoeccciglkfbmbnfm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetstation%2Felectron-chrome-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetstation%2Felectron-chrome-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetstation%2Felectron-chrome-extension/lists"}