Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ragingwind/chrome-manifest
Help you using manifest for Chrome Apps and Extension
https://github.com/ragingwind/chrome-manifest
Last synced: about 1 month ago
JSON representation
Help you using manifest for Chrome Apps and Extension
- Host: GitHub
- URL: https://github.com/ragingwind/chrome-manifest
- Owner: ragingwind
- Created: 2015-02-03T13:22:57.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-18T23:48:08.000Z (over 8 years ago)
- Last Synced: 2024-04-29T21:06:20.389Z (8 months ago)
- Language: JavaScript
- Size: 78.1 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-browser-extensions-and-apps - chrome-manifest - manage manifest, easily include/exclude keys. (Tools / Development)
README
# chrome-manifest [![Build Status](https://travis-ci.org/ragingwind/chrome-manifest.svg?branch=master)](https://travis-ci.org/ragingwind/chrome-manifest)
> Help you manage manifest when you are developing Chrome Apps and Extensions
## Install
```sh
$ npm install --save chrome-manifest
```## Usage
### Manifest
```js
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
```js
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](http://ragingwind.me)