Expand description
A library for modding Electron apps in-memory, without modifying any program files.
This library was made for improving the modding experience for Discord, but it can be used for any Electron app.
§Features
asar: Enables the ASAR archive builder. (enabled by default)uuid: Enables the use of random UUIDs for ASAR archive names. (enabled by default)
§Examples
electron-hook maps the original app.asar to _app.asar,
so keep this in mind if you need to call the original file anywhere,
as shown in this example.
ⓘ
use electron_hook::asar::Asar;
let mod_dir = mod_artifact_dir("moonlight");
let _download_url = "https://github.com/moonlight-mod/moonlight/releases/latest/download/dist.tar.gz";
// extract and save `_download_url` into `mod_dir`
let mod_entrypoint = mod_dir.join("injector.js");
let template = r#"
console.log("Mod injected!!!");
let asar = require("path").resolve(__dirname, "../_app.asar");
require(process.env.MODLOADER_MOD_ENTRYPOINT).inject(asar);
"#;
// Create the asar file
let asar = Asar::new()
.with_id("moonlight")
.with_template(template)
.with_mod_entrypoint(mod_dir)
.create()
.unwrap();
electron_hook::launch(
"/path/to/executable/Discord",
asar.path().to_str().unwrap(),
vec!["--pass-arguments-here"],
None, // Optional profile directory
true, // Detach the process
);Modules§
Enums§
- FlatpakID
- The ID of a Flatpak package.
Functions§
- launch
- Launches an Electron executable with the provided information.
- launch_
flatpak - Launches an Electron executable through Flatpak with the provided information.