Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karlhorky/electron-app-patcher
Patch an Electron app to apply your own changes
https://github.com/karlhorky/electron-app-patcher
Last synced: 3 months ago
JSON representation
Patch an Electron app to apply your own changes
- Host: GitHub
- URL: https://github.com/karlhorky/electron-app-patcher
- Owner: karlhorky
- Created: 2022-10-30T15:10:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-05T19:00:32.000Z (3 months ago)
- Last Synced: 2024-12-05T20:18:16.937Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 554 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Electron App Patcher
Patch an Electron app to apply your own changes (macOS only for now)
## Setup
Electron App Patcher requires a certificate to sign the app again after it has been patched (see https://stackoverflow.com/a/27474942/1268612).
1. Clone the repo and run `pnpm` to install the dependencies
2. Open Keychain Access
3. Open the menu item Keychain Access > Certificate Assistant > Create a Certificate...
4. For the name, enter `electron-app-patcher-self-signed-cert`
5. Under "Certificate Type", select "Code Signing"
6. Create the certificate## Usage
Run `pnpm run patch ` in the `electron-app-patcher` directory, and it will patch your app based on the transforms in the patch file in the `patches/` directory. For example, with the included `patches/signal.ts` patch:
```bash
$ pnpm run patch signal
Creating a backup of app.asar...
Processing preload.bundle.js...
Repacking app.asar to enable patch...
Updating hash in Info.plist to bypass asar integrity check...
Signing app with self-signed certificate...
Done!
✨ Done in 6.66s.
```You will receive a prompt during the app signing to enter your password, since the `codesign` command needs access to the self-signed certificate created in **Setup** above.
After opening the patched app, you may receive a permissions prompt for access to confidential information in your keychain because of the re-signing of the app. Only allow access to information that you believe the app should have access to.
![]()
Screenshot of security notification in macOS showing the messageSignal wants to use your confidential information stored in "Signal Safe Storage" in your keychain.
.
### Restore `app.asar` backup
```bash
$ pnpm run patch signal restore-backup
```### Delete `app.asar` backup
```bash
$ pnpm run patch signal delete-backup
```## How?
Electron App Patcher works by modifying the files inside the [asar archive](https://github.com/electron/asar):
1. `/Contents/Resources/app.asar` is backed up to `/Contents/Resources/app.asar.bak`
2. `/Contents/Resources/app.asar` is extracted to `/Contents/Resources/app/`
3. All transforms in your specified patch file are applied to files in `/Contents/Resources/app/`
4. The contents of `/Contents/Resources/app/` are packed into `/Contents/Resources/app.asar`
5. The SHA256 hash of the header of the `/Contents/Resources/app.asar` file is calculated and updated in the `/Contents/Info.plist` file (to avoid errors from asar integrity check)
6. App is signed with self-signed certificate## Troubleshooting
### macOS Security Warning
Newer versions of macOS may prevent the app where you run the script from modifying apps on your computer and require you to allow access manually:
![]()
Screenshot of security notification in macOS showing the message"Visual Studio Code" was prevented from modifying apps on your Mac
.
## Credit
Credit for the original script goes to [@degecko](https://github.com/degecko):
- https://www.codepicky.com/hacking-electron-restyle-skype
- https://github.com/codepicky/skype-patch