erikvold edited this page Dec 24, 2011 · 5 revisions


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


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).


Object, String or Array


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