Skip to content

Instantly share code, notes, and snippets.

@Deliaz
Created April 8, 2019 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deliaz/31699dbf4636be0be3b7d1638d9da76a to your computer and use it in GitHub Desktop.
Save Deliaz/31699dbf4636be0be3b7d1638d9da76a to your computer and use it in GitHub Desktop.
Shows version of .CRX file (chromium extensions). JavaScript version.
#!/usr/bin/env node
const fs = require('fs');
const filePath = process.argv[2];
if(!filePath) {
console.error('No file specified.\nUsage:\n\tnode crxver.js my-extensions.crx\n');
process.exit(-1);
}
const buf = fs.readFileSync(filePath);
const VERSION_POS_BYTE_OFFSET = 4;
const VERSION_LENGTH_BYTE = 1;
const type = buf.subarray(0, 4).toString('ascii');
const version = buf.readIntBE(VERSION_POS_BYTE_OFFSET, VERSION_LENGTH_BYTE).toString(16);
console.log('File type:\t', type);
console.log('Version:\t', version);
@Deliaz
Copy link
Author

Deliaz commented Apr 8, 2019

Usage:

node crxver.js my-extensions.crx

Output:

File type:	 Cr24
Version:	 3

Bash versions of this script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment