GM.getResourceText: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
(simplify)
Line 11: Line 11:
{{Function|GM_getResourceText|resourceName}}
{{Function|GM_getResourceText|resourceName}}


== Arguments ==
=== Arguments ===


; resourceName
; resourceName
: <code>String</code> The name provided when the [[Metadata Block#.40resource|@resource]] was defined, follow that link for valid naming restrictions.
: <code>String</code> The name provided when the [[Metadata Block#.40resource|@resource]] was defined, follow that link for valid naming restrictions.


== Returns ==
=== Returns ===


<code>String</code>
<code>String</code>


== Raises ==
=== Raises ===


Throws an <code>Error</code> when the named resource does not exist.
Throws an <code>Error</code> when the named resource does not exist.
Line 33: Line 33:
var prototypeSource = GM_getResourceText("prototype");
var prototypeSource = GM_getResourceText("prototype");
</pre>
</pre>
== See Also ==
* [[GM_getResourceURL]]


[[Category:API_Reference|G]]
[[Category:API_Reference|G]]

Revision as of 21:50, 8 February 2010


Description

Given a defined @resource, this method returns it as a string.

Compatibility: Greasemonkey 0.8.0+

Syntax

function GM_getResourceText( resourceName )

Arguments

resourceName
String The name provided when the @resource was defined, follow that link for valid naming restrictions.

Returns

String

Raises

Throws an Error when the named resource does not exist.

Examples

// ==UserScript==
// @resource prototype http://www.example.com/prototype.js
// ==/UserScript==

var prototypeSource = GM_getResourceText("prototype");

See Also