Skip to content

解压 Chrome 插件文件(*.crx)。unzip chrome extension files(*.crx).

License

Notifications You must be signed in to change notification settings

tomjs/unzip-crx

Repository files navigation

@tomjs/unzip-crx

npm node-current (scoped) NPM jsDocs.io

English | 中文

Unzip chrome extension files

If you want to unzip Chrome extension files (*.crx) you might have the problem that your unzip lib claims that the file header is malformed. This is due to that Chrome adds some extra information for identifying crx files. unzip-crx handles those additional headers and unzips as usual.

This library is based on Peerigon's unzip-crx, which makes simple modifications and adds esm and cjs support.

And this unzip-crx is highly inspired by crx2ff from abarreir and crxviewer from Rob Wu, thanks!

Install

# pnpm
pnpm add @tomjs/unzip-crx

# yarn
yarn add @tomjs/unzip-crx

# npm
npm add @tomjs/unzip-crx

Example

  • esm
import unzip from 'unzip-crx';

const crxFile = './this-chrome-extension.crx';

unzip(crxFile).then(() => {
  console.log('Successfully unzipped your crx file..');
});
  • cjs
const unzip = require('unzip-crx');

const crxFile = './this-chrome-extension.crx';

unzip(crxFile).then(() => {
  console.log('Successfully unzipped your crx file..');
});

Documentation

API

unzip(file[, destination])

  • file: string, the path to the file to unzip
  • destination: string, the path to the destination folder (optional)

Resolves with a Promise if the file was unzipped successfully, throws otherwise (use .catch()).