GM.getResourceText: Difference between revisions
From GreaseSpot Wiki
Jump to navigationJump to search
m Text replace - "[[Metadata_block" to "[[Metadata Block" |
simplify |
||
Line 3: | Line 3: | ||
== Description == | == Description == | ||
Given a defined [[Metadata Block#.40resource|@resource]], this method returns it as a string. | |||
Compatibility: [[Version_history#0.8.20080609.0|Greasemonkey 0.8.0+]] | |||
== Syntax == | == Syntax == | ||
{{Function|GM_getResourceText|resourceName}} | |||
== Arguments == | |||
; resourceName | |||
: <code>String</code> The name provided when the [[Metadata Block#.40resource|@resource]] was defined, follow that link for valid naming restrictions. | |||
== Returns == | |||
<code>String</code> | |||
=== | == Raises == | ||
Throws an <code>Error</code> when the named resource does not exist. | |||
== Examples == | == Examples == | ||
<pre class='sample'> | <pre class='sample'> | ||
// ==UserScript== | // ==UserScript== | ||
// @resource prototype http://www.example.com/prototype.js | |||
// @resource | |||
// ==/UserScript== | // ==/UserScript== | ||
var prototypeSource = GM_getResourceText("prototype"); | |||
</pre> | </pre> | ||
[[Category:API_Reference|G]] | [[Category:API_Reference|G]] |
Revision as of 21:43, 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");