JSPM

@tkausl/userscript-meta

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

Parse and stringify Userscript metadata.

Package Exports

  • @tkausl/userscript-meta

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 (@tkausl/userscript-meta) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

userscript-meta

Build Status codecov npm license

Parse and stringify Userscript metadata.

Installation

npm install userscript-meta --save

API

parse(string)

parse userscript metadata to an object.

const userscript = require('userscript-meta')

userscript.parse(`
  // ==UserScript==
  // @name Userscript name
  // @version 1.0
  // @match http://www.example.com/*
  // @match http://www.example.org/*
  // ==/UserScript==
`)

equals to

{
  name: 'Userscript name',
  version: '1.0',
  // Field which has multiple value will parsed to an array
  match: [
    'http://www.exmaple.com/*',
    'http://www.exmaple.org/*',
  ]
}

stringify(object)

const userscript = require('userscript-meta')

userscript.stringify({
  name: 'Userscript name',
  version: '1.0',
  match: [
    'http://www.exmaple.com/*',
    'http://www.exmaple.org/*',
  ]
})

equals to

// ==UserScript==
// @name Userscript name
// @version 1.0
// @match http://www.example.com/*
// @match http://www.example.org/*
// ==/UserScript==

license

MIT