Patch an Electron app to apply your own changes
Patch an Electron app to apply your own changes (macOS only for now)
Electron App Patcher requires a certificate to sign the app again after it has been patched (see https://stackoverflow.com/a/27474942/1268612).
pnpm
to install the dependencieselectron-app-patcher-self-signed-cert
Run pnpm run patch <patch name>
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:
$ 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.
app.asar
backup$ pnpm run patch signal restore-backup
app.asar
backup$ pnpm run patch signal delete-backup
Electron App Patcher works by modifying the files inside the asar archive:
<app>/Contents/Resources/app.asar
is backed up to <app>/Contents/Resources/app.asar.bak
<app>/Contents/Resources/app.asar
is extracted to <app>/Contents/Resources/app/
<app>/Contents/Resources/app/
<app>/Contents/Resources/app/
are packed into <app>/Contents/Resources/app.asar
<app>/Contents/Resources/app.asar
file is calculated and updated in the <app>/Contents/Info.plist
file (to avoid errors from asar integrity check)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:
Credit for the original script goes to @degecko: