• Stars
    star
    516
  • Rank 85,726 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A node.js command line app for packing Google Chrome extensions.

crx Build Status Build status

crx is a utility to package Google Chrome extensions via a Node API and the command line. It is written purely in JavaScript and does not require OpenSSL!

Packages are available to use crx with:

Massive hat tip to the node-rsa project for the pure JavaScript encryption!

Compatibility: this extension is compatible with node>=10.

Install

$ npm install crx

Module API

Asynchronous functions returns a native ECMAScript Promise.

const fs = require('fs');
const path = require('path');

const ChromeExtension = require('crx');

const crx = new ChromeExtension({
  codebase: 'http://localhost:8000/myExtension.crx',
  privateKey: fs.readFileSync('./key.pem')
});

crx.load( path.resolve(__dirname, './myExtension') )
  .then(crx => crx.pack())
  .then(crxBuffer => {
    const updateXML = crx.generateUpdateXML()

    fs.writeFileSync('../update.xml', updateXML);
    fs.writeFileSync('../myExtension.crx', crxBuffer);
  })
  .catch(err=>{
    console.error( err );
  });

ChromeExtension = require("crx")

crx = new ChromeExtension(attrs)

This module exports the ChromeExtension constructor directly, which can take an optional attribute object, which is used to extend the instance.

crx.load(path|files)

Prepares the temporary workspace for the Chrome Extension located at path — which is expected to directly contain manifest.json.

crx.load('/path/to/extension').then(crx => {
  // ...
});

Alternatively, you can pass a list of files — the first manifest.json file to be found will be considered as the root of the application.

crx.load(['/my/extension/manifest.json', '/my/extension/background.json']).then(crx => {
  // ...
});

crx.pack()

Packs the Chrome Extension and resolves the promise with a Buffer containing the .crx file.

crx.load('/path/to/extension')
  .then(crx => crx.pack())
  .then(crxBuffer => {
    fs.writeFileSync('/tmp/foobar.crx', crxBuffer);
  });

crx.generateUpdateXML()

Returns a Buffer containing the update.xml file used for autoupdate, as specified for update_url in the manifest. In this case, the instance must have a property called codebase.

const crx = new ChromeExtension({ ..., codebase: 'https://autoupdateserver.com/myFirstExtension.crx' });

crx.load('/path/to/extension')
  .then(crx => crx.pack())
  .then(crxBuffer => {
    // ...
    const xmlBuffer = crx.generateUpdateXML();
    fs.writeFileSync('/foo/bar/update.xml', xmlBuffer);
  });

crx.generateAppId

Generates application id (extension id) from given path.

new crx().generateAppId('/path/to/ext') // epgkjnfaepceeghkjflpimappmlalchn

CLI API

crx pack [directory] [--crx-version number] [-o file] [--zip-output file] [-p private-key]

Pack the specified directory into a .crx package, and output it to stdout. If no directory is specified, the current working directory is used.

Use the --crx-version option to specify which CRX format version to output. Can be either "2" or "3", defaults to "3".

Use the -o option to write the signed extension to a file instead of stdout.

Use the --zip-output option to write the unsigned extension to a file.

Use the -p option to specify an external private key. If this is not used, key.pem is used from within the directory. If this option is not used and no key.pem file exists, one will be generated automatically.

Use the -b option to specify the maximum buffer allowed to generate extension. By default, will rely on node internal setting (~200KB).

crx keygen [directory]

Generate a 2048-bit RSA private key within the directory. This is called automatically if a key is not specified, and key.pem does not exist.

Use the --force option to overwrite an existing private key located in the same given folder.

crx --help

Show information about using this utility, generated by commander.

CLI example

Given the following directory structure:

└─┬ myFirstExtension
  ├── manifest.json
  └── icon.png

run this:

$ cd myFirstExtension
$ crx pack -o

to generate this:

├─┬ myFirstExtension
│ ├── manifest.json
│ ├── icon.png
│ └── key.pem
└── myFirstExtension.crx

You can also name the output file like this:

$ cd myFirstExtension
$ crx pack -o myFirstExtension.crx

to get the same results, or also pipe to the file manually like this.

$ cd myFirstExtension
$ crx pack > ../myFirstExtension.crx

As you can see a key is generated for you at key.pem if none exists. You can also specify an external key. So if you have this:

├─┬ myFirstExtension
│ ├── manifest.json
│ └── icon.png
└── myPrivateKey.pem

you can run this:

$ crx pack myFirstExtension -p myPrivateKey.pem -o

to sign your package without keeping the key in the directory.

License

MIT License.

More Repositories

1

tld.js

JavaScript API to work easily with complex domain names, subdomains and well-known TLDs.
JavaScript
462
star
2

nodebook

📖 Livre publié aux Éditions Eyrolles • Première édition : Node.js v10 et npm v6.
JavaScript
305
star
3

grunt-crx

Grunt task used to package private Chrome Extensions.
JavaScript
118
star
4

wp-less

WordPress plugin which seemlessly compiles, caches and rebuilds your LESS stylesheets.
PHP
88
star
5

hexo-algolia

Index your hexo website content to Algolia Search.
JavaScript
84
star
6

webextension-fip

Minimalistic WebExtension to listen to FIP Radio, the best eclectic radio station (for Firefox, Chrome, Opera and Edge)
JavaScript
34
star
7

Imager.jsx

A React component for responsive images in desktop and mobile browsers. Featuring Imager.js.
JavaScript
32
star
8

mailto

Transform your HTML forms in beautiful mailto: links, form submission or XHR requests.
JavaScript
14
star
9

letsencrypt-alwaysdata

Update your SSL certs on alwaysdata via their REST API
Shell
12
star
10

coursera-ml

Setup to evolve through the Machine Learning course.
Makefile
10
star
11

detour.studio

Un outil de travail multi-disciplinaire pour cultiver des rituels de pratiques en pair à pair.
HTML
10
star
12

homebrew-brew

Homebrew formula to install cpdf and Lightroom Classic CC 5.7 on macOS.
Ruby
9
star
13

mindmeister-php

PHP library to access Mindmeister REST API (http://www.mindmeister.com/services/api)
PHP
9
star
14

asciidoctor-extension-interactive-runner

Turn your Asciidoc code listings into interactive playgrounds in web browsers.
JavaScript
8
star
15

Jobs

Want to apply for a dev job? Pull request!
7
star
16

thom4.net

A work in progress of my digital mind, my digital avatars and real-world artefacts.
HTML
7
star
17

vue-waveform-template

A Vue.js component to embed and annotate an audio file, visualized as a waveform, thanks to BBC Peaks.js
Vue
7
star
18

content-edit

HTML Content Edit (jQuery) plugin. To edit content with a more complex workflow than just an inline editable.
JavaScript
7
star
19

is-webview

A JavaScript library to indicate if we are dealing with a WebView or a Web page.
JavaScript
6
star
20

asciidoctor-prism-extension

Highlight code listings with Prism.js, server side, with no front-end dependencies.
JavaScript
6
star
21

11ty-stylo

Carnet web propulsé par Eleventy, et des données hébergées sur Stylo
JavaScript
5
star
22

talks

Public talks provided either in English or French, about JavaScript or human-centric topics.
5
star
23

asciidoctor-converter-opendocument

Convert Asciidoc documents to OpenDocument (`.odt`) files.
JavaScript
5
star
24

data.emunova.net

Contient les données qui permettent de générer une version statique du site Emu Nova.
JavaScript
4
star
25

photography

My own photography website. For leaner and nicer layouts than services out there.
JavaScript
4
star
26

react-inliner

React components rendered and inlined server-side.
JavaScript
4
star
27

html-game-of-life

The Game of Life, with HTML, JavaScript and DOM.
JavaScript
3
star
28

sfRedisCachePlugin

Redis cache backend for Symfony
PHP
3
star
29

uwa-vcub

UWA Widget for VCUB Bordeaux / CUB bike service
PHP
3
star
30

elevato.rs

Learning web technologies by fixing elevators
JavaScript
3
star
31

talktimer.js

Have to keep your speaker on time? Show them a countdown! Used at @sudweb.
JavaScript
3
star
32

m2-min-2020

Module Développement Web (MIN 306) du « Master innovation & transformation numérique »
HTML
2
star
33

m2-min-2018

Cours de développement web pour le Master 2 « Innovation et Transformation Numérique » de TélécomParisTech.
HTML
2
star
34

emunova.net

Application frontend d'un site contributif dédié au rétrogaming et à l'émulation de jeux vidéo.
HTML
2
star
35

print-pad

Turn a HackMD/CodiMD/HedgeDoc pad as a printable and paginated document. Self-hostable.
CSS
2
star
36

reactzine

A mobile first magasine prototype app using React.
JavaScript
2
star
37

bbc-pid

Simple JavaScript API to validate Programme Identifier (PID) syntax and to compute BBC URLs.
JavaScript
2
star
38

cyneticmonkey.com

Fortunately, it's not written in Leetspeak.
JavaScript
2
star
39

m2-min-2019

Module Développement Web (MIN 306) du « Master innovation & transformation numérique »
HTML
2
star
40

wp-amazon-widgets-shortcodes

Keep your time and save your money with these Amazon widgets shortcodes. Standard compliants, easy to use and so on!
PHP
2
star
41

reading-time-stream

Input a Stream text in, get a reading time out. A super fast Buffer-only reading time calculation.
JavaScript
1
star
42

yeswiki-release-action

Crée un artéfact distribuable d'une extension ou thème YesWiki
Shell
1
star
43

hexo-theme

Hexo theme for my portfolio and stuff.
JavaScript
1
star
44

test-website-repo-3796

1
star
45

app.emunova.net

The inevitable Heroku app to perform OAuth and CORS requests on the behalf of the user.
JavaScript
1
star
46

pandoc-notion-subpages-filter

Assemble Notion.so Export subpages into a single document with this Pandoc filter.
Lua
1
star
47

wp-canalblog-importer

Imports a whole Canalblog blog into a WordPress instance.
PHP
1
star
48

everyday-sequence

Everyday in picture, one day at a time. Since 2012.
JavaScript
1
star
49

wordpress-mindmeister-shortcode

Easy Mindmeister embeding within WordPress posts.
PHP
1
star
50

wp-meta-view-count

Post/page view count for WordPress working through server-cache.
PHP
1
star
51

input-search

Unit tested HTML5 polyfill for input[type="search"] element.
JavaScript
1
star
52

wp-theme-toolkit

Starter files for a good and easy WordPress theme
PHP
1
star
53

grunt-testing-workshop

Learning to refactor and test Grunt Tasks within BBC News and BBC R&D.
JavaScript
1
star
54

reveal-random-colors

Pimp your Reveal.js presentations by randomising the colours and fonts of the current slide.
JavaScript
1
star
55

behind-the-code-readme-article

A selection of ideas to write well structured and nicely formatted README — Behind the Code's source code of the same name article.
1
star
56

vagrant-opencaster-it950x

Vagrant OpenCaster + it950x configuration
Shell
1
star