# node_inject **Repository Path**: qian-song/node_inject ## Basic Information - **Project Name**: node_inject - **Description**: Typora 补丁注入 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-14 - **Last Updated**: 2024-11-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NodeInject An inject tools for injecting js code into electron application Please follow DMCA when using this code ### Requirement > [!TIP] > > **Requirement cargo gcc git** ```bash #安装cargo #官方文档如下 #https://forge.rust-lang.org/infra/other-installation-methods.html#standalone-installers [root@almalinux ~]# wget https://static.rust-lang.org/dist/rust-1.82.0-x86_64-unknown-linux-gnu.tar.xz [root@almalinux ~]# tar xf rust-1.82.0-x86_64-unknown-linux-gnu.tar.xz [root@almalinux ~]# cd rust-1.82.0-x86_64-unknown-linux-gnu/ [root@almalinux ~/rust-1.82.0-x86_64-unknown-linux-gnu]# ll total 108 -rw-r--r-- 1 root root 21109 Oct 16 01:22 COPYRIGHT -rw-r--r-- 1 root root 9723 Oct 16 01:22 LICENSE-APACHE -rw-r--r-- 1 root root 1023 Oct 16 01:22 LICENSE-MIT -rw-r--r-- 1 root root 3137 Oct 16 01:22 README.md -rw-r--r-- 1 root root 9171 Oct 16 01:22 builder-config drwxr-xr-x 5 root root 60 Nov 14 12:20 cargo drwxr-xr-x 4 root root 49 Nov 14 12:20 clippy-preview -rw-r--r-- 1 root root 230 Oct 16 01:22 components -rw-r--r-- 1 root root 40 Oct 16 01:22 git-commit-hash -rw-r--r-- 1 root root 62 Oct 16 01:22 git-commit-info -rwxr-xr-x 1 root root 29433 Oct 16 01:22 install.sh drwxr-xr-x 3 root root 36 Nov 14 12:20 llvm-bitcode-linker-preview drwxr-xr-x 3 root root 36 Nov 14 12:20 llvm-tools-preview drwxr-xr-x 4 root root 49 Nov 14 12:20 rls-preview drwxr-xr-x 3 root root 36 Nov 14 12:20 rust-analysis-x86_64-unknown-linux-gnu drwxr-xr-x 4 root root 49 Nov 14 12:20 rust-analyzer-preview drwxr-xr-x 3 root root 38 Nov 14 12:20 rust-docs drwxr-xr-x 3 root root 38 Nov 14 12:20 rust-docs-json-preview -rw-r--r-- 1 root root 2 Oct 16 01:22 rust-installer-version drwxr-xr-x 3 root root 36 Nov 14 12:20 rust-std-x86_64-unknown-linux-gnu drwxr-xr-x 6 root root 75 Nov 14 12:20 rustc drwxr-xr-x 4 root root 49 Nov 14 12:20 rustfmt-preview -rw-r--r-- 1 root root 29 Oct 16 01:22 version #执行安装脚本 [root@almalinux ~/rust-1.82.0-x86_64-unknown-linux-gnu]# bash install.sh #安装编译环境gcc [root@almalinux ~/rust-1.82.0-x86_64-unknown-linux-gnu]# cd [root@almalinux ~]# yum install gcc git -y ``` ### How it works 1. unpack `node_modules.asar` package (in `./resources`) 2. write `hook.js` into `raven` package directory (raven will be required at the early stage of startup in some application) 3. modify `index.js` of `raven`,injecting require of `hook.js` > Currently using embedded javascript file (`hooklog.js`) ### Usage 1. modify `hook.js` if you need or enable `no_embed` feature to use specified js (`NO_EMBED_HOOK_JS_PATH`) at runtime 2. use `cargo build` to make executable with embedded js or `cargo build --features no_embed` without embedded js 3. Move the program to the electron application directory 4. run ### Compatibility test - Windows / Typora 1.4.8 PASSED - Ubuntu / Typora 1.4.7 PASSED Since macos may adopt different packaging methods and webkit as the execution environment, this tool does not support applications under macos. ### Examples https://github.com/DiamondHunters/NodeInject_Hook_example :Use NodeInject to realize specific functions in Typora