npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

crx-util

v1.0.0

Published

Download (and extract) Chrome/Edge extension (.crx).

Downloads

776

Readme

crx-util

Download (and extract) Chrome/Edge extension (.crx).

Install

npm install crx-util

Usage

const crx = require("crx-util");

// Download a CRX file from microsoft webstore
crx.downloadByURL(`https://microsoftedge.microsoft.com/addons/detail/${extensionName}/${extensionId}`, "./xxx.crx")
  .then((res) => {
    if (res.result) {
      console.info("succeed!");
    } else {
      console.warn("Failed:", res.error);
    }
    // Other info
    const { extensionId, source, downloadURL, output } = res;
  });

// Download by extension id and source
crx.downloadById(`${extensionId}`, "edge", "./xxx.crx");

// Download and extract
crx.downloadById(`${extensionId}`, "edge", "./xxx");

// Download from google webstore
crx.downloadByURL(`https://chrome.google.com/webstore/detail/${extensionName}/${extensionId}`, "./xxx.crx");

// Or by extension id and source
crx.downloadById(`${extensionId}`, "chrome", "./xxx.crx");

// Extract a local CRX file
crx.parser.extract("./xxx.crx", "./xxx");

CLI

Usage

# Download by webstore url
crx-util -u=url [-o=output]

# Download by extension id and source
crx-util -i=extensionId -s=source [-o=output]

# Extract a local CRX file
Usage: crx-util -e=crxPath [-o=output]

Example:

# Download a CRX file from microsoft webstore
crx-util -u="https://microsoftedge.microsoft.com/addons/detail/$name/$id" -o="./xxx.crx"

# Download and extract
crx-util -i="$id" -s="edge" -o="./xxx"

# Extract a local CRX file
crx-util -e="./xxx.crx" -o="./xxx"

Arguments

  • -u, --url - Chrome/Edge extension url
  • -i, --id - Extension id
  • -s, --source - Extension source, "chrome" or "edge"
  • -e, --extract - Extract a local CRX file
  • -o, --output - Output, if it ends with .crx, it will be saved as a CRX file, otherwise it will be extracted to ${output}/${extensionId}. Default by process.cwd().
  • -h, --help - Display help for command

API

crx.downloadByURL(url, output?): Promise

Download a CRX file from webstore.

  • url string - Chrome/Edge extension url
  • output string (optional) - If output ends with ".crx", it will be saved as a CRX file, otherwise it will be extracted to ${output}/${extensionId}. Default by process.cwd().

Resolves with an object contains the following info:

  • result Boolean
  • error any
  • extensionId String
  • source "chrome" | "edge"
  • downloadURL String
  • output String

crx.downloadById(extensionId, source, output?): Promise

Download a CRX file by extension id and source.

  • extensionId string - Extension id
  • source "chrome" | "edge" - Extension source
  • output string (optional) - If output ends with ".crx", it will be saved as a CRX file, otherwise it will be extracted to ${output}/${extensionId}. Default by process.cwd().

Resolves with an object.

crx.downloader

crx.downloader.URL_PATTERN

Download url pattern.

  • chrome string
  • edge string

crx.downloader.parseURL(url): Object

Parse Chrome/Edge extension url.

  • url string - Chrome/Edge extension url.

Returns an object contains extensionId and source ("chrome" or "edge") info.

crx.downloader.getDownloadURL(extensionId, source): String

Get download url by extensionId and source.

  • extensionId string - Extension id
  • source "chrome" | "edge" - Extension source

Returns the download url.

crx.downloader.downloadByURL(url): Promise

Download a CRX file by url.

  • url string - Chrome/Edge extension url.

Resolves with CRX buffer.

crx.downloader.downloadById(extensionId, source): Promise

Download a CRX file by extension id and source.

  • extensionId string - Extension id
  • source "chrome" | "edge" - Extension source

Resolves with CRX buffer.

crx.parser

crx.parser.isCrx(crxPathOrBuffer): Boolean

Checks whether the given path or Buffer contains a valid CRX file.

  • crxPathOrBuffer string | Buffer - CRX file path or buffer.

crx.parser.getCrxVersion(crxPathOrBuffer): Number

Get CRX version.

  • crxPathOrBuffer string | Buffer - CRX file path or buffer.

crx.parser.getZipContents(crxPathOrBuffer): Buffer

Convert a CRX Buffer to a Zip Buffer.

  • crxPathOrBuffer string | Buffer - CRX file path or buffer.

crx.parser.extract(crxPathOrBuffer, output?)

Extract a local CRX file.

  • crxPathOrBuffer string | Buffer - CRX file path or buffer.
  • output string (optional) - It will be extracted to ${output}/${crxFileName}. Default by process.cwd().