Created
April 8, 2019 05:22
-
-
Save Deliaz/31699dbf4636be0be3b7d1638d9da76a to your computer and use it in GitHub Desktop.
Shows version of .CRX file (chromium extensions). JavaScript version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Output:
Bash versions of this script