userscript-header-format
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Userscript header formatter

release npm

Tool to format userscript headers from js.

Usage:

import UserscriptHeader from "userscript-header-formatter";

const header = UserscriptHeader.fromObject({
  name: "My cool userscript",
  namespace: "https://example.com",
  version: "0.1.0",
  description: "very cool indeed",
  author: "me",
  match: [
    "https://github.com/*",
    "https://gitlab.com/*"
  ]
}).toString();

Header, generated from this code will be:

// ==UserScript==
// @name         My cool userscript
// @namespace    https://example.com
// @version      0.1.0
// @description  very cool indeed
// @author       me
// @match        https://github.com/*
// @match        https://gitlab.com/*
// ==/UserScript==

Api declarations

type Value = string | number;

interface Field {
  name: string;
  value: Value;
}

interface HeaderDescriptor {
  [index: string]: Value | Array<Value>;
}

declare class Header {
  constructor(fields: Field[]);
  static fromObject(object: HeaderDescriptor): Header;
  toString(): string;
}

export default Header;

Readme

Keywords

Package Sidebar

Install

npm i userscript-header-format

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

3.5 kB

Total Files

4

Last publish

Collaborators

  • lerarosalene