New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

generate-userscript-header

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generate-userscript-header

Generates a userscript header string to append to your scripts.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
1
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

About

This module generates a userscript header string to append to your scripts.

Usage

First install: npm install generate-userscript-header

Then you can use it:

var generateUserscriptHeader = require('generate-userscript-header');

var userscript = {
	'name': 'ACME Userscript Maker',
	'namespace': 'http://example.com/',
	'author': '{{{pkg.author}}}',
	'homepage': '{{{pkg.homepage}}}',
	'grant': 'none',
	'include': [
		'http://google.com/*',
		'https://google.com/*'
	]
};

var context = {
	pkg: {
		author: 'John Doe',
		homepage: 'http://example.com/johndoe'
	}
};

var header = generateUserscriptHeader(userscript, context);

console.log(header);

Output:

// ==UserScript==
// @name ACME Userscript Maker
// @namespace http://example.com/
// @author John Doe
// @homepage http://example.com/johndoe
// @grant none
// @include http://google.com/*
// @include https://google.com/*
// ==/UserScript==

API

This module exports a single method that outputs a userscript metadata block as a string given the data to convert. Data is parsed with mustache and replaced with the data of a certain context.

Syntax

var generate = require('generate-userscript-header');
generate(userscript, context)

Parameters

NameTypeDescription
userscriptobjectThe object containing the userscript data.
contextobjectThe data used to parse values with mustache. Use {{{yourKey}}} in the data to parse.

Return

TypeDescription
stringThe finalized metadata block.

Keywords

userscript

FAQs

Package last updated on 21 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts