Chrome Extensions | Browsers
Standards Based Development
CRX (.crx) Package Format
CRX files are ZIP files with a special header and the .crx file extension.
Package header
The header contains the author's public key and the extension's signature. The signature is generated from the ZIP file using SHA-1 with the author's private key. The header requires a little-endian byte ordering with 4-byte alignment. The following table describes the fields of the .crx header in order:
| Field | Type | Length | Value | Description |
|---|---|---|---|---|
| magic number | char[] | 32 bits | Cr24 | Chrome requires this constant at the beginning of every .crx package. |
| version | unsigned int | 32 bits | 2 | The version of the *.crx file format used (currently 2). |
| public key length unsigned int | 32 bits pubkey.length The length of the RSA public key in bytes. | |||
| signature length unsigned int | 32 bits sig.length The length of the signature in bytes. | |||
| public key byte[] pubkey.length pubkey.contents The contents of the author's RSA public key, formatted as an X509 SubjectPublicKeyInfo block. | ||||
| signature byte[] sig.length sig.contents The signature of the ZIP content using the author's private key. The signature is created using the RSA algorithm with the SHA-1 hash function. |
Extension Contents
The extension's ZIP file is appended to the *.crx package after the header. This should be the same ZIP file that the signature in the header was generated from as shown in the next example. The following is an example hex dump from the beginning of a .crx file:
43 72 32 34 # "Cr24" -- the magic number
02 00 00 00 # 2 -- the crx format version number
A2 00 00 00 # 162 -- length of public key in bytes
80 00 00 00 # 128 -- length of signature in bytes
........... # the contents of the public key
........... # the contents of the signature
........... # the contents of the zip file
Packaging Scripts
Roll your own packaging script(s): there's already a Ruby script (crxmake), and a Bash script available for use in packaging .crx files.
SOMETHING
Chrome Extensions are small software programs built on html, css, and JavaScript, that have the ability to modify and enhance Chrome's functionality.
Chrome Extensions bundle all of their files into a single file for the user to download and install. The way Chrome Extensions bundle ensures that Chrome Extensions do not need to depend on content from the web, unlike typical web applications.
Chrome Extensions can be distributed using the Chrome Developer Dashboard to publish to the Chrome Web Store.
Getting Started
Check Chrome Extension Boilerplate and Chrome Extension css.
Extenzionizr
Extenzionizr allows you to download a chrome extension boilerplate, with simple configuration of the manifest.json file.
Extenzionizr works like this, on pageload zip.js imports the pre-made zip file. Once the user has selected some options, they are collected and a list of properties is created to add and remove from the zip. The removing is done twice, because some of the properties are manifest entries (omnibox permission), some are plain files (jQuery), and some are both (page action). Once all of the settings get collected, and the user clicks download file, Extenzionizr runs through the properties, and edits the zip file, removing any unnesecary files, while also updating manifest.json. After this is done, it spits the Base64 blob into an a element. Using Chrome's a [download] property, the file then is downloaded to the user's machine.
More documentation on Extenzionizr can be found in this introduction blog post, as well as on GitHub.
Extension Demos
- 01 Google Chrome Extension Demo
- chromeskel Google Chrome Extension Demo
- extensionizr Google Chrome Extension Demo
- hello world Google Chrome Extension Demo
- sandwhichbar Google Chrome Extension Demo (Shows an infobar on pages which contain the word 'sandwich')
- webinfopedia Google Chrome Extension Demo