cm

chrome-manifest

Help you using manifest for Chrome Apps and Extension

Showing:

Popularity

Downloads/wk

31

GitHub Stars

9

Maintenance

Last Commit

5yrs ago

Contributors

0

Package

Dependencies

5

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

chrome-manifest Build Status

Help you manage manifest when you are developing Chrome Apps and Extensions

Install

$ npm install --save chrome-manifest

Usage

Manifest

var Manifest = require('chrome-manifest');
var manifest = new Manifest('manifest.json');

// exclude value or key what you want
manifest.exclude([
  {
    // you can use string array expression to access array property
    'content_scripts.[0].matches': [
      "http://*/*"
    ]
  },
  {
    'background.scripts': [
      'scripts/willbe-remove-only-for-debug.js',
      'scripts/user-script.js'
    ]
  },
  'manifest_version',
  'key'
]);

// get/set
console.log(manifest.content_scripts.[0].matches.length);
console.log(manifest.content_scripts.[0]);
console.log(manifest.background.scripts);
console.log(manifest.manifest_version);
console.log(manifest.manifest['key']);

// patch version from 0.0.1 to 0.0.2
manifest.patch();

// Get various types
console.log(manifest.toJSON());
console.log(manifest.toBuffer());
console.log(manifest.toString());

Metadata

Generating manifest.json with basic sample configures

var Manifest = require('chrome-manifest');

// Query permissions by stable and platform_app(Chrome Apps)
var metadata = Manifest.queryMetadata({
  channel: 'stable',
  extensionTypes: ['platform_app']
});

// Create a manifest with selected fields and permissions of Chrome Manifest
var manifest = new Manifest({
  fields: Object.keys(metadata.fields),
  permissions: Object.keys(metadata.permissions)
});

// Merge with new value
manifest.merge({
  name: 'My Apps',
  author: 'New Author',
  app: {
    background: {
      scripts: [
        "scripts/background.js",
        "scripts/addmore.js"
      ]
    }
  },
  permissions: [
    'tabs',
    'http://*/**',
    'https://*/**',
    'test permissions'
  ]
});

assert.equal(manifest.name, 'My Apps');
assert.equal(manifest.author, 'New Author');
assert.equal(manifest.app.background.scripts.length, 2);
assert.equal(manifest.app.background.scripts[1], 'scripts/addmore.js');
assert(manifest.permissions.indexOf('test permissions') >= 0);

License

MIT ©Jimmy Moon

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial