JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 37
  • Score
    100M100P100Q59752F
  • License MIT

Userscript metadata parser.

Package Exports

  • userscript-parser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (userscript-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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' ],
    license: [ 'MIT License' ]
  },
  metablock: "// ==UserScript==...",
  content: "\n\nvar whoami = 'USERSCRIPT'\n"
}

License

MIT @ Amio