Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mike10004/crxtool

Tool for packing and unpacking Chrome extension .crx files
https://github.com/mike10004/crxtool

chrome-extension java library metadata

Last synced: 3 months ago
JSON representation

Tool for packing and unpacking Chrome extension .crx files

Awesome Lists containing this project

README

        

[![Travis build status](https://img.shields.io/travis/mike10004/crxtool.svg)](https://travis-ci.org/mike10004/crxtool)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/bb3s40548ffj3uf5?svg=true)](https://ci.appveyor.com/project/mike10004/crxtool)
[![Maven Central](https://img.shields.io/maven-central/v/com.github.mike10004/crxtool.svg)](https://repo1.maven.org/maven2/com/github/mike10004/crxtool/)

# crxtool

Library for packing and unpacking Chrome extension `.crx` files.

## Core Library

### Maven Coordinates


com.github.mike10004
crxtool-core
0.15

### Usage

#### Unpacking

try (InputStream in = new FileInputStream("my_extension.crx") {
CrxMetadata metadata = CrxParser.getDefault().parseMetadata(in);
System.out.println("id = " + metadata.getId());
// handle remainder of stream as a zip archive
try (ZipInputStream zin = new ZipInputStream(in)) {
// ...
}
}

#### Packing

Path extensionDir = new File("manifest-parent-dir").toPath();
java.security.KeyPairGenerator keyGen = java.security.KeyPairGenerator.getInstance("RSA");
java.security.SecureRandom random = new java.security.SecureRandom();
keyGen.initialize(1024, random);
java.security.KeyPair keyPair = keyGen.generateKeyPair();
try (OutputStream out = new FileOutputStream("new_extension.crx")) {
CrxPacker.getDefault().packExtension(extensionDir, keyPair, out);
}

## Maven Plugin

### Maven Coordinates


com.github.mike10004
crxtool-maven-plugin
0.15

### Usage

Place extension source files in `src/main/extension`.




com.github.mike10004
crxtool-maven-plugin
0.15


pack

pack-extension





org.codehaus.mojo
build-helper-maven-plugin
3.0.0


attach-artifact

attach-artifact




${project.build.directory}/${project.artifactId}-${project.version}.crx
crx







## Credits

The extension ID construction is probably from [this Stack Overflow answer](https://stackoverflow.com/a/2050916/2657036).
The make-page-red example extension file in the test resources is from [developer.chrome.com](https://developer.chrome.com/extensions/samples).