Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-module-extractor

js-module-extractor is a lightweight Python CLI tool that extracts and beautifies JavaScript modules from a plain text file. It scans for lines using the pattern __d("moduleName", ...), extracts the module name, formats the code, and writes each module to a separate .js file.

Features

  • Detects JavaScript module definitions in __d("...") format
  • Extracts and saves each module into its own file
  • Beautifies the code using jsbeautifier
  • CLI usage via js-module-extractor command

Installation

Install directly from the GitHub repository:

pip install git+https://github.com/maxipalacios/js-module-extractor.git

Usage

After installing, you can run it from the command line:

js-module-extractor input_file.txt
  • input_file.txt: A UTF-8 encoded text file with one or more __d("moduleName", ...) lines.

Output

The tool will create a folder named output_modules/ (if not already present) and generate one file per module:

output_modules/
└── MyModule.js

Each file contains beautified code extracted from the original input.

Example

Input line:

__d("MyModule", function(global, require, module, exports) { /* code */ }, 123);

Command:

js-module-extractor modules.txt

Result:

output_modules/
└── MyModule.js

Development Setup

Clone the repo and install in editable mode:

git clone https://github.com/maxipalacios/js-module-extractor.git
cd js-module-extractor
pip install -e .

Run locally:

js-module-extractor path/to/input.txt

License

This tool is provided under an open license for educational and practical use. Feel free to modify or extend it to fit your needs.

About

A utility tool for extracting and reconstructing JavaScript modules from plain text sources. It identifies module definitions, beautifies the code using jsbeautifier, and writes each module to a separate .js file in the output directory. Useful for reverse engineering or refactoring bundled scripts.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages