0.2.0 • Published 8 years ago

userscript-header v0.2.0

Weekly downloads
3
License
-
Repository
github
Last release
8 years ago

userscript-header

Generate userscript header from package.json.

Usage

Example package.json :

{
  "name": "my-userscript",
  "version": "0.1.0",
  "description": "Userscript description",
  "author": "Author",
  "license": "MIT",
  "devDependencies": {
    "gulp": "^3.9.1"
  },
  "userscript": {
    "name": "My userscript name",
    "description": "My userscript description",
    "author": "Toast",
    "namespace": "http://www.spawnkill.fr",
    "match": "*://*.toast.tld/*",
    "grant": [
      "GM_addStyle",
      "GM_setClipboard"
    ],
    "run-at": "document-start"
  }
}
var UserscriptHeader = require('userscript-header');

var userscriptHeader = UserscriptHeader.fromPackage('./package.json');

userscriptHeader.getData();

// Returns :

// {
//   'name': 'My userscript name',
//   'author': 'Toast',
//   'version': '0.1.0',
//   'description': 'My userscript description',
//   'namespace': 'http://www.spawnkill.fr',
//   'match': '*://*.toast.tld/*',
//   'grant': [
//      'GM_addStyle',
//      'GM_setClipboard',
//   ],
//   'run-at': 'document-start',
// }


console.log(header.toString());

// Output :

// ==UserScript==
// @name My userscript name
// @author Toast
// @version 0.1.0
// @description My userscript description
// @namespace http://www.spawnkill.fr
// @match *://*.toast.tld/*
// @grant GM_addStyle
// @grant GM_setClipboard
// @run-at document-start
// ==/UserScript==

When present, package.userscript.{name|version|description|author}, respectively override package.{name|version|description|author}.

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago