Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

GM_getMetadata

erikvold edited this page · 5 revisions

Description

GM_getMetadata retrieves the value(s) of a user script's metadata block @keys.

Arguments

String key

The name of the metadata block @key.

Note: all @keys are lowercased, so if you used @Version (which you shouldn't do) then a version key will be defined in the object that is returned by GM_getMetadata.

Boolean local

Optional. If true then the value that Scriptish is using (instead of the value actually in the script) will be returned. For example, if you don't include a @homepage then you can discover what Scriptish recorded as your @homepage with GM_getMetadata("homepage", true).

Returns

Object, String or Array

Example

var myName = GM_getMetadata("name");
var myDescription = GM_getMetadata("description");
alert("User Script: " + myName + "\nDescription: " + myDescription);

// log headers keys
var headers = GM_getMetadata();
for (var prop in headers)
  console.log("header @key name is: " + prop);

Related Pages

Manual: API

Something went wrong with that request. Please try again.