Metadata Block

From GreaseSpot Wiki
Revision as of 02:18, 20 November 2006 by Ldrhcp (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The metadata block is a section of a user script that does not execute any code, but describes the script. It contains the script name, namespace, description, and include and exclude rules.

The metadata block appears in Javascript comments. It begins with the line

// == UserScript==

and ends with

// == /UserScript==

Everything between those lines is in the format

// @key   value

If the metadata block includes a key that Greasemonkey does not understand, it will simply be ignored.

Metadata keys

@name

The name of the script. This appears in the script manager and monkey menu, and is also used to determine whether to overwrite an old version of a script or to install it separately. If no name is provided, it will be inferred from the file name.

@namespace

The namespace, along with the name, is used to determine whether to overwrite an old version of a script or to install it separately. A script author will usually put all of their scripts under one common namespace, and then assign each script a unique name. If two scripts have the same name, but a different namespace, they can co-exist. However, two scripts of the same name in the same namespace are assumed to be replacements for one another. While the namespace is non-semantic, it should be a URI. If no namespace is provided, it is assumed to be the domain from which the script is installed. Since a script can live on various servers or on a local file system, authors should specify this.

@description

Just a description.

@include and @exclude

Refer to Include and exclude rules. There can be any number of @include and @exclude rules in a script.

Example

// ==UserScript==
// @name          My Script
// @namespace     http://www.example.com/gmscripts/
// @description   Scripting is fun
// @include       http://www.example.com/*
// @include       http://www.example.org/*
// @exclude       http://www.example.org/foo
// ==/UserScript==