Download (and extract) Chrome/Edge extension (.crx).
npm install crx-utilbash
npm install crx-util
`
Usage
`javascript
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
$3
`bash
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]
`
$3
`bash
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"
`
$3
- -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
$3
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
$3
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.
$3
#### 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.
$3
#### 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()`.