Greasemonkey Chrome



  1. Greasemonkey Vs Chrome Extension
  2. Greasemonkey Chrome
  3. Greasemonkey Chrome Download
  4. Greasemonkey Chrome Extension
  5. Greasemonkey Chrome Download

Description

If you want full Greasemonkey support in Chrome, use Tampermonkey. Clearing up confusion about User scripts in Chrome. Chrome does not natively support GreaseMonkey. Whenever a.user.js file is loaded, it's converted to a Chrome extension in form of a Content script. Greasemonkey allows you to customize the way popular websites look and behave by tweaking their functionality with a script. In fact Greasemonkey is not an application in itself. It’s a Firefox add-on that prepares your browser to support Greasemonkey scripts. The add-on puts a small monkey icon in the bottom right corner, from where you can.

The metadata block is a section of a user script that describes the script.It usually contains the script name, namespace, description, and include and exclude rules.The metadata block appears in JavaScript line comments and may appear anywhere in the top level Greasemonkey code scope of the script, but is usually near the top of the file.

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

Syntax

The metadata block must follow the format:

It must use line comments (//) like above, not block comments (/* */).Note that the opening // UserScript and closing // /UserScript must be precisely at the beginning of its line.Some keys may have multiple values.In all cases the key and value(s) are separated by whitespace.The closing /UserScript line should be at the end of the metadata block (not at the end of the script).

@description

Example:

Just a brief summary of what the script does, presented to the user as the script is installed, and in the manage dialog.

As of Greasemonkey 2.2: can be localized for multiple languages; see the #@name documentation for more detail.

@exclude

Examples: see @include

See Include and exclude rules.There can be any number of @exclude rules in a script.

@grant

See dedicated @grant page.

@icon

Example:

The icon is, as of Greasemonkey 0.9.0, displayed in the script management interface.Almost any image will work, but a 32x32 pixel size is best.This value may be specified relative to the URL the script itself is downloaded from.

@include

Examples:

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

@match

Examples:

The @match metadata imperative is very similar to @include, however it is safer.It sets more strict rules on what the * character means.

For details, see the documentation on Match Patterns for Google Chrome.Chrome implemented @match first, and Greasemonkey has been designed to be compatible.

Chrome

@name

Example:

The name of the script.This appears in the monkey menu, and is also the unique identifier of a script (within a namespace).If no name is provided, it will be derived from the file name.

As of Greasemonkey 2.2: can be localized for multiple languages, for example:

Add a colon and the locale code, which is the ISO 639 language code and optionally a hyphen and ISO 3166 country code, when disambiguation is necessary.When the user's browser is configured with the matching primary language, that value will be displayed instead.

@namespace

Example:

The combination of namespace and name is the unique identifier for a Greasemonkey script.If a script is being installed, and a script with that same name and namespace already exists, it will be replaced by the new script.Otherwise, the new script is added to the set of installed scripts.A script author will usually put all of their scripts under one common namespace, and then assign each script a unique name.

While the namespace is non-semantic, a URL is often used.Some authors use the common home page for the collection of scripts they have written.But remember, the namespace can be any unique value.

@noframes

Example: Two bad antsthird grade reading streets.

When present, this imperative restricts the execution of the script.The script will run only in the top-level document, never in nested frames.It takes no arguments, it is either present or not present.This is off (scripts run in frames) by default.

@require

Example:

There can be any number of @require keys in a script.Each @require is downloaded once, when the script is installed, and stored on the user's hard drive alongside the script.The URL specified may be relative to the URL the script is being installed from.

Note that since Greasemonkey 0.9.0, if Greasemonkey detects that the @require value(s) have been altered, these new values will be used (thus each @require shall be re-downloaded).

Little miss sunshine, reporting for duty!. See also:

@resource

Example:

Greasemonkey Vs Chrome Extension

There can be any number of @resource keys in a script.

While the resourceName is non-semantic, it should comply with JavaScript identifier restrictions.Each @resource must have a unique name.

Each @resource is downloaded once, when the script is installed, and stored on the user's hard drive alongside the script.The URL specified may be relative to the URL the script is being installed from.

These named resources may be accessed through GM_getResourceText and GM_getResourceURL respectively.

Note that since Greasemonkey 0.9.0, if Greasemonkey detects that the @resource value(s) have been altered, these new values will be used (thus each @resource shall be re-downloaded).

See also:

@run-at

Compatibility: Limited support in Greasemonkey 4.0.

Example:

This key supports three values:

document-end
The default if no value is provided. The script will run after the main page is loaded, but before other resources (images, style sheets, etc.) have loaded. The only guaranteed working value in Greasemonkey 4.x.
document-start
The script will run before any document begins loading, thus before any scripts run or images load.
document-idle
The script will run after the page and all resources (images, style sheets, etc.) are loaded and page scripts have run.

To detect if you are running at document-start time, check the value of document.readyState.For example:

Greasemonkey Chrome

Download

Scripts running at document-end will have the value interactive here.


@version

Example:

Greasemonkey Chrome Download

Examples

Adding Resources

Two metadata imperatives allow downloading files (once, at install time) for efficient reference:First @require, which includes a remote code resource.Second @resource, which makes a remote data resource available.

Greasemonkey Chrome Extension

It is possible to add a new entry for either of these values, while editing a script that is already installed.In either case, simply add the appropriate line and the referenced file will be downloaded and made available the next time the script runs.If you specify a relative URL, then it will be interpreted as relative to the the URL the script was originally downloaded from.

Greasemonkey Chrome Download

See Also

Notes

Retrieved from 'https://wiki.greasespot.net/index.php?title=Metadata_Block&oldid=7626'