2.2.2 • Published 6 years ago

userscript-parser v2.2.2

Weekly downloads
11
License
MIT
Repository
github
Last release
6 years ago

userscript-parser npm-version install size

Userscript metadata parser.

Usage

const userscriptText = '// ==UserScript==...'
const usp = require('userscript-parser')

const { meta, metablock, content } = usp(userscriptText)

Given this userscript:

// ==UserScript==
// @name        Awesome Script
// @description This script even does the laundry!
// @downloadURL https://www.example.com/myscript.user.js
// @homepageURL https://github.com/gantt/downloadyoutube
// @author      Gantt
// @version     1.8.3
// @date        2015-05-17
// @include     https://www.youtube.com/*
// @exclude     https://www.youtube.com/embed/*
// @match       https://www.youtube.com/*
// @grant       GM_xmlhttpRequest
// @grant       GM_getValue
// @grant       GM_setValue
// @run-at      document-end
// @license     MIT License
// ==/UserScript==

var whoami = 'USERSCRIPT'

will produce this parsed object:

{
  meta: {
    description: [ 'This script even does the laundry!', ],
    downloadURL: [ 'https://www.example.com/myscript.user.js' ],
    name: [ 'Awesome Script' ],
    homepageURL: [ 'https://github.com/gantt/downloadyoutube' ],
    author: [ 'Gantt' ],
    version: [ '1.8.3' ],
    date: [ '2015-05-17' ],
    include: [ 'https://www.youtube.com/*' ],
    exclude: [ 'https://www.youtube.com/embed/*' ],
    match: [ 'https://www.youtube.com/*' ],
    grant: [ 'GM_xmlhttpRequest', 'GM_getValue', 'GM_setValue' ],
    'run-at': [ 'document-end' ],
    license: [ 'MIT License' ]
  },
  metablock: "// ==UserScript==...",
  content: "\n\nvar whoami = 'USERSCRIPT'\n"
}

License

MIT @ Amio

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

7 years ago

1.0.0

7 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago