userscript-meta-f4w

1.0.2 • Public • Published

userscript-meta-f4w

Fork from the original userscript-meta by pd4d10.

Changes made in the stringify function only:

  • Give more space between the key and the value
  • Trim the value for keys that don't have value, like @noframes.

Build Status codecov npm license

Parse and stringify Userscript metadata.

Installation

npm install userscript-meta-f4w --save

API

parse(string)

parse userscript metadata to an object.

const userscript = require('userscript-meta-f4w');

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

Produces

{
  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 { stringify } = require('userscript-meta-f4w');
const { name, version, description, author, license } = require('./package.json');

const metadata = {
  name,
  version,
  namespace: `https://github.com/${author}`,
  description,
  author,
  match: ['*://*/*'],
  grant: [
    //
    'GM.getValue',
    'GM_getValue',
    'GM.setValue',
    'GM_setValue',
    'GM.xmlHttpRequest',
    'GM_xmlhttpRequest',
    'GM.setClipboard',
    'GM_setClipboard',
  ],
  'run-at': 'document-start',
  noframes: '',
  compatible: [
    //
    'edge Tampermonkey or Violentmonkey',
    'firefox Greasemonkey, Tampermonkey or Violentmonkey',
    'chrome Tampermonkey or Violentmonkey',
    'opera Tampermonkey or Violentmonkey',
  ],
  supportURL: `https://github.com/${author}/${name}/issues`,
  homepageURL: `https://github.com/${author}/${name}`,
  updateURL: `https://github.com/${author}/${name}/raw/main/dist/${name}.meta.js`,
  downloadURL: `https://github.com/${author}/${name}/raw/main/dist/${name}.user.js`,
  icon: 'https://violentmonkey.github.io/icons/icon-48x48.png', // https://www.google.com/s2/favicons?sz=64&domain=github.com
  license,
};

stringify(metadata);

Produces

// ==UserScript==
// @name           userscript-gulp-template
// @version        0.0.1
// @namespace      https://github.com/FlowerForWar
// @description    User script template that acts as module and tries to simulate imports
// @author         FlowerForWar
// @match          *://*/*
// @grant          GM.getValue
// @grant          GM_getValue
// @grant          GM.setValue
// @grant          GM_setValue
// @grant          GM.xmlHttpRequest
// @grant          GM_xmlhttpRequest
// @grant          GM.setClipboard
// @grant          GM_setClipboard
// @run-at         document-start
// @noframes
// @compatible     edge Tampermonkey or Violentmonkey
// @compatible     firefox Greasemonkey, Tampermonkey or Violentmonkey
// @compatible     chrome Tampermonkey or Violentmonkey
// @compatible     opera Tampermonkey or Violentmonkey
// @supportURL     https://github.com/FlowerForWar/userscript-gulp-template/issues
// @homepageURL    https://github.com/FlowerForWar/userscript-gulp-template
// @updateURL      https://github.com/FlowerForWar/userscript-gulp-template/raw/main/dist/userscript-gulp-template.meta.js
// @downloadURL    https://github.com/FlowerForWar/userscript-gulp-template/raw/main/dist/userscript-gulp-template.user.js
// @icon           https://violentmonkey.github.io/icons/icon-48x48.png
// @license        MIT
// ==/UserScript==

license

MIT

Package Sidebar

Install

npm i userscript-meta-f4w

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

7.75 kB

Total Files

4

Last publish

Collaborators

  • flower4war