https://wiki.greasespot.net/api.php?action=feedcontributions&user=LouCypher&feedformat=atomGreaseSpot Wiki - User contributions [en]2024-03-28T22:22:31ZUser contributionsMediaWiki 1.41.0https://wiki.greasespot.net/index.php?title=Metadata_Block&diff=7412Metadata Block2014-03-09T20:13:00Z<p>LouCypher: /* @match */ Replace old link with the newer</p>
<hr />
<div>== Description ==<br />
<br />
The '''metadata block''' is a section of a [[user script]] that describes the script.<br />
It usually contains the script name, namespace, description, and [[include and exclude rules]].<br />
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.<br />
<br />
If the metadata block includes a key that Greasemonkey does not understand, it will simply be ignored.<br />
Some authors choose to include their own keys, and [http://userscripts.org userscripts.org] defines a set of metadata keys for varying purposes.<br />
<br />
As of [[Version_history#0.9.0|Greasemonkey 0.9.0]], the metadata block is reloaded any time the file changes, just like the rest of the source in the script.<br />
In any older version, one must re-install the script for metadata changes to be recognized.<br />
In 0.9.0+, editing the script is how (e.g.) <code>@include</code> and <code>@exclude</code> rules are customized.<br />
All of the metadata imperatives can be added, removed, or changed, but be careful with the <code>@name</code> and <code>@namespace</code> imperatives: their combination must remain unique among installed scripts, so changing them can cause problems.<br />
<br />
== Syntax ==<br />
<br />
The metadata block must follow the format:<br />
<br />
<pre class='sample'><br />
// ==UserScript==<br />
// @key value<br />
// ==/UserScript==<br />
</pre><br />
<br />
It must use line comments (<code>//</code>) like above, not block comments (<code>/* */</code>).<br />
Note that the opening <code>// ==UserScript==</code> and closing <code>// ==/UserScript==</code> must be precisely at the beginning of its line.<br />
Some keys may have multiple values.<br />
In all cases the key and value(s) are separated by whitespace.<br />
The closing <code>==/UserScript==</code> line should be at the end of the metadata block (not at the end of the script).<br />
<br />
=== @description ===<br />
<br />
Example:<br />
// @description This script even does the laundry!<br />
<br />
Just a brief summary of what the script does, presented to the user as the script is installed, and in the manage dialog.<br />
<br />
=== @downloadURL ===<br />
<br />
The URL to download this script from, when installing updates.<br />
<br />
<nowiki>// @downloadURL https://www.example.com/myscript.user.js</nowiki><br />
<br />
Greasemonkey's default settings require this value to be secure (<tt><nowiki>https://...</nowiki></tt>) for updates to be applied.<br />
If it is not specified, the URL the script was originally installed from will be used.<br />
<br />
=== @exclude ===<br />
<br />
Examples: see @include<br />
<br />
See [[Include and exclude rules]].<br />
There can be any number of @exclude rules in a script.<br />
<br />
=== @grant ===<br />
<br />
See dedicated [[@grant]] page.<br />
<br />
=== @icon ===<br />
<br />
Compatibility: [[Version_history#0.9.0|Greasemonkey 0.9.0+]]<br />
<br />
Example:<br />
<nowiki>// @icon http://www.example.org/icon.png</nowiki><br />
<br />
The icon is, as of Greasemonkey 0.9.0, displayed in the script management interface.<br />
Almost any image will work, but a 32x32 pixel size is best.<br />
<br />
=== @include ===<br />
<br />
Examples:<br />
<nowiki>// @include http://www.example.com/*</nowiki><br />
<nowiki>// @include http://*</nowiki><br />
<nowiki>// @include *</nowiki><br />
<br />
See [[Include and exclude rules]].<br />
There can be any number of @include rules in a script.<br />
<br />
=== @match ===<br />
<br />
:Compatibility: [[Version_history#0.9.8|Greasemonkey 0.9.8+]]<br />
<br />
Examples:<br />
<nowiki>// @match https://www.example.com/*</nowiki><br />
<nowiki>// @match http://*.example.com/*</nowiki><br />
<br />
The <code>@match</code> metadata imperative is very similar to <code>@include</code>, however it is safer.<br />
It sets more strict rules on what the <code>*</code> character means.<br />
<br />
For details, see the documentation on [https://developer.chrome.com/extensions/match_patterns Match Patterns] for Google Chrome.<br />
Chrome implemented <code>@match</code> first, and Greasemonkey has been designed to be compatible.<br />
<br />
=== @name ===<br />
<br />
Example:<br />
// @name Example Script<br />
<br />
The name of the script.<br />
This appears in the [[Greasemonkey_Manual:Manage_Dialog|script manager]] and [[Greasemonkey_Manual:Monkey_Menu|monkey menu]], and is also the unique identifier of a script (within a [[#@namespace|namespace]]).<br />
If no name is provided, it will be derived from the file name.<br />
<br />
=== @namespace ===<br />
<br />
Example:<br />
<nowiki>// @namespace http://www.example.com/gmscripts</nowiki><br />
<br />
The combination of namespace and name is the unique identifier for a Greasemonkey script.<br />
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.<br />
Otherwise, the new script is added to the set of installed scripts.<br />
A script author will usually put all of their scripts under one common namespace, and then assign each script a unique name.<br />
<br />
While the namespace is non-semantic, a URL is often used.<br />
Some authors use the common home page for the collection of scripts they have written.<br />
But remember, the namespace can be any unique value.<br />
<br />
=== @require ===<br />
<br />
Compatibility: [[Version_history#0.8.20080609.0|Greasemonkey 0.8.0+]]<br />
<br />
Example:<br />
<nowiki>// @require http://www.example.com/example.js</nowiki><br />
<br />
There can be any number of @require keys in a script.<br />
Each @require is downloaded once, when the script is installed, and stored on the user's hard drive alongside the script.<br />
The URL specified may be relative to the URL the script is being installed from.<br />
<br />
Note that since [[Version_history#0.9.0|Greasemonkey 0.9.0]], if Greasemonkey detects that the <code>@require</code> value(s) have been altered, these new values will be used (thus each <code>@require</code> shall be re-downloaded).<br />
<br />
See also:<br />
<br />
* [[:Category:@require Library]]<br />
* [[#Adding Resources]]<br />
<br />
=== @resource ===<br />
<br />
:Compatibility: [[Version_history#0.8.20080609.0|Greasemonkey 0.8.0+]]<br />
<br />
Example:<br />
<nowiki>// @resource resourceName http://www.example.com/example.png</nowiki><br />
<br />
There can be any number of @resource keys in a script.<br />
<br />
While the resourceName is non-semantic, it should comply with JavaScript identifier restrictions.<br />
Each @resource must have a unique name.<br />
<br />
Each @resource is downloaded once, when the script is installed, and stored on the user's hard drive alongside the script.<br />
The URL specified may be relative to the URL the script is being installed from.<br />
<br />
These named resources may be accessed through [[GM_getResourceText]] and [[GM_getResourceURL]] respectively.<br />
<br />
Note that since [[Version_history#0.9.0|Greasemonkey 0.9.0]], if Greasemonkey detects that the <code>@resource</code> value(s) have been altered, these new values will be used (thus each <code>@resource</code> shall be re-downloaded).<br />
<br />
See also:<br />
<br />
* [[#Adding Resources]]<br />
<br />
=== @run-at ===<br />
<br />
:Compatibility: [[Version_history#0.9.8|Greasemonkey 0.9.8+]]<br />
<br />
Example:<br />
<nowiki>// @run-at document-end</nowiki><br />
<br />
Supports two values: <code>document-end</code> and <code>document-start</code>.<br />
<br />
End is the standard behavior that Greasemonkey has always had (see [[DOMContentLoaded]]).<br />
This is the default if no value is provided.<br />
<br />
Start is new as of version 0.9.8.<br />
The script will run before any document begins loading, thus before any scripts run or images load.<br />
<br />
To detect if you are running at <code>document-start</code> time, check the value of <code>[https://developer.mozilla.org/en/DOM/document.readyState document.readyState]</code>.<br />
For example:<br />
<br />
<pre class="sample-good"><br />
if ('loading' == document.readyState) {<br />
alert("This script is running at document-start time.");<br />
} else {<br />
alert("This script is running with document.readyState: " + document.readyState);<br />
}<br />
</pre><br />
<br />
Scripts running at <code>document-end</code> will have the value <code>interactive</code> here.<br />
<br />
=== @unwrap ===<br />
<br />
Compatibility: [[Version_history#0.8.20090123.1|Greasemonkey 0.8.1]] through 0.9.22<br />
<br />
'''Note: This key has been removed from [[Version_history#1.0_2|version 1.0+]]'''<br />
<br />
Example:<br />
// @unwrap<br />
<br />
This declarative key has no associated value.<br />
It changes the interpretation of the script as it executes.<br />
<br />
Normally, Greasemonkey scripts are wrapped in an anonymous function when they are executed.<br />
This behavior started in very early versions of Greasemonkey, which ran scripts directly in the content page, to separate their variables from those in the page.<br />
In later versions, it remains because isolating the script from the [[sandbox]] scope still helps in certain cases.<br />
<br />
This key is strongly recommended to only be used for [[Global_object#Debugging|debugging]] purposes.<br />
<br />
=== @updateURL ===<br />
<br />
The URL that Greasemonkey will download when checking for script updates.<br />
<br />
<nowiki>// @updateURL https://www.example.com/myscript.meta.js</nowiki><br />
<br />
This URL need only contain the metadata block.<br />
If the [[#@version|@version]] specified here is newer than the installed version, an update will be offered to the user.<br />
<br />
=== @version ===<br />
<br />
Compatibility: [[Version_history#0.9.0|Greasemonkey 0.9.0+]]<br />
<br />
Example:<br />
// @version 1.0<br />
<br />
This is the version of the script, which should be treated like a [https://developer.mozilla.org/en/install_manifests#version firefox extension version], and maintain the [https://developer.mozilla.org/en/Extension_Versioning%2c_Update_and_Compatibility same syntax].<br />
<br />
The version is used by the auto-update feature implemented in [[Version_history#0.9.12|Greasemonkey 0.9.12]]. When this value is set, and if the auto-update feature is enabled, Greasemonkey will check periodically for new versions of the script by downloading it again from the location where the installed version of the script was downloaded, and compare the @version value in the newly downloaded script with that value in the installed script.<br />
With previous versions of Greasemonkey 0.9.0+, this value was only used for display in the script management interface.<br />
<br />
== Examples ==<br />
<br />
<pre class='sample'><nowiki><br />
// ==UserScript==<br />
// @name My Script<br />
// @namespace http://www.example.com/gmscripts<br />
// @description Scripting is fun<br />
// @include http://www.example.com/*<br />
// @include http://www.example.org/*<br />
// @exclude http://www.example.org/foo<br />
// @require foo.js<br />
// @resource resourceName1 resource1.png<br />
// @resource resourceName2 http://www.example.com/resource2.png<br />
// @version 1.0<br />
// @icon http://www.example.net/icon.png<br />
// ==/UserScript==<br />
</nowiki></pre><br />
<br />
== Adding Resources ==<br />
<br />
Two metadata imperatives allow downloading files (once, at install time) for efficient reference:<br />
First [[#@require|@require]], which includes a remote code resource.<br />
Second [[#@resource|@resource]], which makes a remote data resource available.<br />
<br />
It is possible to add a new entry for either of these values, while editing a script that is already installed.<br />
In either case, simply add the appropriate line and the referenced file will be downloaded and made available the next time the script runs.<br />
If you specify a relative URL, then it will be interpreted as relative to the the URL the script was originally downloaded from.<br />
If there was no original download URL (i.e. a brand new script created from a local file), then this will work if you also create an appropriately named file alongside the script. (As of Greasemonkey 1.0.)<br />
<br />
== See Also ==<br />
<br />
* [[API reference]]<br />
* [[Knowing Your Own Metadata]]<br />
* [[Third-Party Libraries]]<br />
<br />
== Notes ==<br />
<br />
[[Category:API Reference]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=User_Script_Hosting&diff=7409User Script Hosting2014-03-04T17:12:07Z<p>LouCypher: Replaced links with 'https' on /* OpenUserJS.org */ and UserScripts.org sections</p>
<hr />
<div>== Gist ==<br />
<br />
https://gist.github.com/<br />
<br />
Gist is GitHub's "paste" service, where any set of simple files can be pasted into a web form and saved.<br />
Gist files may be named. If they are given the <code>.user.js</code> suffix, then the raw link for the gist will serve perfectly as an install.<br />
HTTPS is available and used by default.<br />
<br />
== Greasy Fork ==<br />
<br />
https://greasyfork.org/<br />
<br />
Created by the maintainer of http://userstyles.org/.<br />
HTTPS is available and enforced by default.<br />
[https://github.com/JasonBarnabe/greasyfork Open source], hosted on GitHub.<br />
<br />
== OpenUserJS.org ==<br />
<br />
https://openuserjs.org/<br />
<br />
"An open source user scripts repo built using Node.js".<br />
HTTPS is available and used by default.<br />
[https://github.com/OpenUserJs/OpenUserJS.org Open source], hosted on GitHub.<br />
<br />
== UserScripts.org ==<br />
<br />
https://userscripts.org/<br />
<br />
One of the original and longest running user script hosting sites.<br />
HTTPS is available but not used/linked to by default.<br />
As of 2014, largely fallen into disrepair.<br />
<br />
== The Whole Internet ==<br />
<br />
Any server across the entire web may host user scripts.<br />
For Greasemonkey, the only requirement is that the (entire) URL ends with <code>.user.js</code> and that it is not served with a <code>text/html</code> content type.<br />
Servers supporting HTTPS are best, in order to be compatible with Greasemonkey's built in update checker.</div>LouCypherhttps://wiki.greasespot.net/index.php?title=User_Script_Hosting&diff=7407User Script Hosting2014-03-03T18:03:44Z<p>LouCypher: /* Greasy Fork */ Added link to repo</p>
<hr />
<div>== Gist ==<br />
<br />
https://gist.github.com/<br />
<br />
Gist is GitHub's "paste" service, where any set of simple files can be pasted into a web form and saved.<br />
Gist files may be named. If they are given the <code>.user.js</code> suffix, then the raw link for the gist will serve perfectly as an install.<br />
HTTPS is available and used by default.<br />
<br />
== Greasy Fork ==<br />
<br />
https://greasyfork.org/<br />
<br />
Created by the maintainer of http://userstyles.org/.<br />
HTTPS is available and enforced by default.<br />
[https://github.com/JasonBarnabe/greasyfork Open source], hosted on GitHub.<br />
<br />
== OpenUserJS.org ==<br />
<br />
http://openuserjs.org/<br />
<br />
"An open source user scripts repo built using Node.js".<br />
[https://github.com/OpenUserJs/OpenUserJS.org Open source], hosted on GitHub.<br />
(As of March 2014) HTTPS is not available.<br />
<br />
== UserScripts.org ==<br />
<br />
http://userscripts.org/<br />
<br />
One of the original and longest running user script hosting sites.<br />
HTTPS is available but not used/linked to by default.<br />
As of 2014, largely fallen into disrepair.<br />
<br />
== The Whole Internet ==<br />
<br />
Any server across the entire web may host user scripts.<br />
For Greasemonkey, the only requirement is that the (entire) URL ends with <code>.user.js</code> and that it is not served with a <code>text/html</code> content type.<br />
Servers supporting HTTPS are best, in order to be compatible with Greasemonkey's built in update checker.</div>LouCypherhttps://wiki.greasespot.net/index.php?title=User_Script_Hosting&diff=7406User Script Hosting2014-03-03T17:59:01Z<p>LouCypher: Moved /* The Whole Internet */ to the bottom</p>
<hr />
<div>== Gist ==<br />
<br />
https://gist.github.com/<br />
<br />
Gist is GitHub's "paste" service, where any set of simple files can be pasted into a web form and saved.<br />
Gist files may be named. If they are given the <code>.user.js</code> suffix, then the raw link for the gist will serve perfectly as an install.<br />
HTTPS is available and used by default.<br />
<br />
== Greasy Fork ==<br />
<br />
https://greasyfork.org/<br />
<br />
Created by the maintainer of http://userstyles.org/.<br />
HTTPS is available and enforced by default.<br />
[ Open source], hosted on GitHub.<br />
<br />
== OpenUserJS.org ==<br />
<br />
http://openuserjs.org/<br />
<br />
"An open source user scripts repo built using Node.js".<br />
[https://github.com/OpenUserJs/OpenUserJS.org Open source], hosted on GitHub.<br />
(As of March 2014) HTTPS is not available.<br />
<br />
== UserScripts.org ==<br />
<br />
http://userscripts.org/<br />
<br />
One of the original and longest running user script hosting sites.<br />
HTTPS is available but not used/linked to by default.<br />
As of 2014, largely fallen into disrepair.<br />
<br />
== The Whole Internet ==<br />
<br />
Any server across the entire web may host user scripts.<br />
For Greasemonkey, the only requirement is that the (entire) URL ends with <code>.user.js</code> and that it is not served with a <code>text/html</code> content type.<br />
Servers supporting HTTPS are best, in order to be compatible with Greasemonkey's built in update checker.</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Template:GitTicket&diff=7344Template:GitTicket2013-08-03T16:18:35Z<p>LouCypher: categorized</p>
<hr />
<div><span class="plainlinks">[http://github.com/greasemonkey/greasemonkey/issues/{{{1}}} #{{{1}}}]</span><br />
<br />
<noinclude><br />
[[Category:Templates]]<br />
</noinclude></div>LouCypherhttps://wiki.greasespot.net/index.php?title=Include_and_exclude_rules&diff=7343Include and exclude rules2013-08-03T14:51:19Z<p>LouCypher: /* Greaseable schemes */ Notes for 'data' scheme</p>
<hr />
<div>[[User script]]s specify include and exclude rules in the [[metadata block]].<br />
<br />
'''The script will execute if it matches any include rule, as long as it does not match an exclude rule.'''<br />
<br />
The rules are URLs, which can have a "wildcard" asterisk (*), which matches any string including the empty string. For example: <code><nowiki>http://www.example.com/foo/*</nowiki></code> will match:<br />
<br />
* <code><nowiki>http://www.example.com/foo/bar</nowiki></code> and,<br />
* <code><nowiki>http://www.example.com/foo/</nowiki></code><br />
<br />
but not:<br />
<br />
* <code><nowiki>http://www.example.com/baz/</nowiki></code>.<br />
<br />
== Globs ==<br />
<br />
Include and exclude rules support the <code>*</code> or [[wikipedia:Glob (programming)|globbing operator]].<br />
The <code>*</code> serves as a wildcard that matches one or more of any character.<br />
A rule can have several wildcards or none, in which case the rule must match the entire URL exactly.<br />
Exclude rules look the same, and prevent the script from being executed.<br />
For example:<br />
<br />
<pre class="sample"><br />
// ==UserScript==<br />
// @include <nowiki>http://www.example.com/foo/*</nowiki><br />
// @include <nowiki>http://www.example.org/*.bar</nowiki><br />
// @exclude <nowiki>http://www.example.com/foo/baz</nowiki><br />
// ==/UserScript==<br />
</pre><br />
<br />
If no include rule is provided, <code>@include *</code> is assumed.<br />
That is: every URL will be matched, within the allowed [[#Greaseable_schemes |Greaseable schemes]].<br />
<br />
== Regular Expressions ==<br />
<br />
As of [[Version_history#0.9.8|Greasemonkey 0.9.8]], support for full regular expressions in include and exclude rules was added.<br />
If the rule both starts and ends with a forward-slash (<code>/</code>) character, the contents inside those slashes are interpreted as a a regular expression.<br />
For example:<br />
<br />
<pre class="sample"><br />
// ==UserScript==<br />
// @include <nowiki>/^https?://www\.example\.com/.*$/</nowiki><br />
// @include <nowiki>/^http://www\.example\.(org|net)//</nowiki><br />
// ==/UserScript==<br />
</pre><br />
<br />
Note:<br />
* The rule is parsed as a standard javascript <code>new RegExp()</code>, so you do not need to escape forward slashes inside the rule. Special regex characters (like <code>.</code>) '''should''' still be escaped, as in the above examples; otherwise they have their normal regex meaning (like <code>.</code> matching any non-newline character).<br />
* The rule is always treated as case insensitive.<br />
* Anchors (<code>^</code>, <code>$</code>) are not supplied for you. If desired, they should be used as in the above example.<br />
<br />
== Greaseable schemes ==<br />
<br />
Greasemonkey will run scripts only on documents loaded from particular [http://tools.ietf.org/html/rfc3986#section-3.1 schemes].<br />
By default, those are:<br />
<br />
* http<br />
* https<br />
* ftp<br />
* data (see Notes)<br />
<br />
=== Notes ===<br />
* What is officially called a 'scheme' in a URL is also found in Javascript as the <code>.protocol</code> property of any abstract <code>link</code> element such as <code>&lt;a&gt;</code>, <code>&lt;link&gt;</code>, or a DOM object such as <code>document.location</code>.<br />
* Supports for 'data' scheme has been removed since version 1.11 due to security issue ({{GitTicket|1767}}).<br />
<br />
== Extra schemes ==<br />
<br />
Greasemonkey will also run scripts on:<br />
<br />
; file:<br />
: Only if <code>greasemonkey.fileIsGreaseable</code> is set to <code>true</code> in [http://kb.mozillazine.org/About:config about:config].<br />
; about:<br />
: <s>Prior to 0.9.8, scripts would only run if <code>greasemonkey.aboutIsGreaseable</code> is set to <code>true</code> in [http://kb.mozillazine.org/About:config about:config]. (But about:blank is always allowed.)</s>.<br />
: Since 0.9.8, only about:blank is allowed and only when explicitly included. ({{GitTicket|1375}})<br />
<br />
In both cases this restriction is intended to prevent security/privacy vulnerabilities.<br />
<br />
== Magic TLD ==<br />
<br />
The only special syntax besides the wildcard is .tld. An include such as <code><nowiki>http://www.example.tld/*</nowiki></code> will match any top level domain, such as <code>www.example.com</code>, <code>www.example.org</code>, <code>www.example.co.uk</code>, and so on. One must be careful with this, to not accidentally leak data to a site that they did not mean to match. This list of TLDs includes myriad dual-segment TLDs (such as ca.us, aeroport.fr and kyoto.jp), beside the plain country or category codes (com, jp, se). For a full list see the [[Magic TLD]] page.<br />
<br />
== Data scheme user scripts ==<br />
<br />
Browsers can open windows in which all of the page top content is contained in a [http://en.wikipedia.org/wiki/Data_URI_scheme data scheme URI].<br />
For example, the below URI will display a HTML page that indirectly includes an image from google.com as its sole content:<br />
<br />
<nowiki>data:text/html;charset=utf-8,<html><head><title>data: test</title></head><body><img src='http://www.google.com/intl/en_ALL/images/logo.gif'></body></html></pre></nowiki><br />
<br />
[http://tinyurl.com/yl8djvy This link] points to the above data URI and can be clicked to see it in action.<br />
<br />
Firefox ignores unknown semicolon separated parameters in the header of a <code>data</code> URI (and the standards seem to leave this possibility open) which means if one adds say the string <code>MyScript;</code> in the header of the above URI, giving:<br />
<br />
data:text/html;MyScript;charset=utf-8,<html><head><title>data: test</title>....<br />
<br />
one can then use [[Include and exclude rules]] such as<br />
<br />
@include data:text/html;MyScript;*<br />
<br />
to trigger user scripts to run on a subtype of <code>data</code> URIs.<br />
<br />
This ability can be useful if a user script creates one or more <code>data</code> URIs and then opens them. Augmenting the URIs with some extra marking can cause specific user scripts to run in their windows. For example, a user script can create a <code>data URI</code> that contains a HTML <code>table</code> and trigger a user script for it that allows the user sort it.<br />
<br />
== User Specified Rules ==<br />
<br />
Since Greasemonkey [[Version history#0.9.9|0.9.9]], users have been able to specify their own exclude and include values through the script options dialog in the Add Ons Manager.<br />
Thus, each script has its own rules plus optionally the user's rules.<br />
<br />
The user's rules are checked first, then the script's rules are checked.<br />
If any exclude matches the page, the script does not run.<br />
If any include matches the page, the script will run.<br />
If a script include matches, but a user exclude also matches, the user exclude will take precedence over the script, and it will not run.<br />
If a script exclude matches, but a user include also matches, the user include will take precedence over the script, and it will run.</div>LouCypherhttps://wiki.greasespot.net/index.php?title=File_talk:Win7-ff4-toolbar-monkey-menu.png&diff=7268File talk:Win7-ff4-toolbar-monkey-menu.png2013-03-29T14:32:05Z<p>LouCypher: /* Outdated */</p>
<hr />
<div>== Outdated ==<br />
The screenshot needs to be updated with the new Monkey Menu (Web sites, Options).<br />
I don't have permissions to do this [http://wiki.greasespot.net/index.php?title=Special:Upload&wpDestFile=Win7-ff4-toolbar-monkey-menu.png].<br />
--[[User:LouCypher|LouCypher]] ([[User talk:LouCypher|talk]]) 10:32, 29 March 2013 (EDT)</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Include_and_exclude_rules&diff=7240Include and exclude rules2013-01-24T19:20:23Z<p>LouCypher: Undo revision 7239 by LouCypher (talk) // Oops! Didn't see it</p>
<hr />
<div>[[User script]]s specify include and exclude rules in the [[metadata block]].<br />
<br />
'''The script will execute if it matches any include rule, as long as it does not match an exclude rule.'''<br />
<br />
The rules are URLs, which can have a "wildcard" asterisk (*), which matches any string including the empty string. For example: <code><nowiki>http://www.example.com/foo/*</nowiki></code> will match:<br />
<br />
* <code><nowiki>http://www.example.com/foo/bar</nowiki></code> and,<br />
* <code><nowiki>http://www.example.com/foo/</nowiki></code><br />
<br />
but not:<br />
<br />
* <code><nowiki>http://www.example.com/baz/</nowiki></code>.<br />
<br />
== Globs ==<br />
<br />
Include and exclude rules support the <code>*</code> or [[wikipedia:Glob (programming)|globbing operator]].<br />
The <code>*</code> serves as a wildcard that matches one or more of any character.<br />
A rule can have several wildcards or none, in which case the rule must match the entire URL exactly.<br />
Exclude rules look the same, and prevent the script from being executed.<br />
For example:<br />
<br />
<pre class="sample"><br />
// ==UserScript==<br />
// @include <nowiki>http://www.example.com/foo/*</nowiki><br />
// @include <nowiki>http://www.example.org/*.bar</nowiki><br />
// @exclude <nowiki>http://www.example.com/foo/baz</nowiki><br />
// ==/UserScript==<br />
</pre><br />
<br />
If no include rule is provided, <code>@include *</code> is assumed.<br />
That is: every URL will be matched, within the allowed [[#Greaseable_schemes |Greaseable schemes]].<br />
<br />
== Regular Expressions ==<br />
<br />
As of [[Version_history#0.9.8|Greasemonkey 0.9.8]], support for full regular expressions in include and exclude rules was added.<br />
If the rule both starts and ends with a forward-slash (<code>/</code>) character, the contents inside those slashes are interpreted as a a regular expression.<br />
For example:<br />
<br />
<pre class="sample"><br />
// ==UserScript==<br />
// @include <nowiki>/^https?://www\.example\.com/.*$/</nowiki><br />
// @include <nowiki>/^http://www\.example\.(org|net)//</nowiki><br />
// ==/UserScript==<br />
</pre><br />
<br />
Note:<br />
* The rule is parsed as a standard javascript <code>new RegExp()</code>, so you do not need to escape forward slashes inside the rule. Special regex characters (like <code>.</code>) '''should''' still be escaped, as in the above examples; otherwise they have their normal regex meaning (like <code>.</code> matching any non-newline character).<br />
* The rule is always treated as case insensitive.<br />
* Anchors (<code>^</code>, <code>$</code>) are not supplied for you. If desired, they should be used as in the above example.<br />
<br />
== Greaseable schemes ==<br />
<br />
Greasemonkey will run scripts only on documents loaded from particular [http://tools.ietf.org/html/rfc3986#section-3.1 schemes].<br />
By default, those are:<br />
<br />
* http<br />
* https<br />
* ftp<br />
* data<br />
<br />
(<b>Note:</b> What is officially called a 'scheme' in a URL is also found in Javascript as the <code>.protocol</code> property of any abstract <code>link</code> element such as <code>&lt;a&gt;</code>, <code>&lt;link&gt;</code>, or a DOM object such as <code>document.location</code>.)<br />
<br />
== Extra schemes ==<br />
<br />
Greasemonkey will also run scripts on:<br />
<br />
; file:<br />
: Only if <code>greasemonkey.fileIsGreaseable</code> is set to <code>true</code> in [http://kb.mozillazine.org/About:config about:config].<br />
; about:<br />
: <s>Prior to 0.9.8, scripts would only run if <code>greasemonkey.aboutIsGreaseable</code> is set to <code>true</code> in [http://kb.mozillazine.org/About:config about:config]. (But about:blank is always allowed.)</s>.<br />
: Since 0.9.8, only about:blank is allowed and only when explicitly included. ({{GitTicket|1375}})<br />
<br />
In both cases this restriction is intended to prevent security/privacy vulnerabilities.<br />
<br />
== Magic TLD ==<br />
<br />
The only special syntax besides the wildcard is .tld. An include such as <code><nowiki>http://www.example.tld/*</nowiki></code> will match any top level domain, such as <code>www.example.com</code>, <code>www.example.org</code>, <code>www.example.co.uk</code>, and so on. One must be careful with this, to not accidentally leak data to a site that they did not mean to match. This list of TLDs includes myriad dual-segment TLDs (such as ca.us, aeroport.fr and kyoto.jp), beside the plain country or category codes (com, jp, se). For a full list see the [[Magic TLD]] page.<br />
<br />
== Data scheme user scripts ==<br />
<br />
Browsers can open windows in which all of the page top content is contained in a [http://en.wikipedia.org/wiki/Data_URI_scheme data scheme URI].<br />
For example, the below URI will display a HTML page that indirectly includes an image from google.com as its sole content:<br />
<br />
<nowiki>data:text/html;charset=utf-8,<html><head><title>data: test</title></head><body><img src='http://www.google.com/intl/en_ALL/images/logo.gif'></body></html></pre></nowiki><br />
<br />
[http://tinyurl.com/yl8djvy This link] points to the above data URI and can be clicked to see it in action.<br />
<br />
Firefox ignores unknown semicolon separated parameters in the header of a <code>data</code> URI (and the standards seem to leave this possibility open) which means if one adds say the string <code>MyScript;</code> in the header of the above URI, giving:<br />
<br />
data:text/html;MyScript;charset=utf-8,<html><head><title>data: test</title>....<br />
<br />
one can then use [[Include and exclude rules]] such as<br />
<br />
@include data:text/html;MyScript;*<br />
<br />
to trigger user scripts to run on a subtype of <code>data</code> URIs.<br />
<br />
This ability can be useful if a user script creates one or more <code>data</code> URIs and then opens them. Augmenting the URIs with some extra marking can cause specific user scripts to run in their windows. For example, a user script can create a <code>data URI</code> that contains a HTML <code>table</code> and trigger a user script for it that allows the user sort it.<br />
<br />
== User Specified Rules ==<br />
<br />
Since Greasemonkey [[Version history#0.9.9|0.9.9]], users have been able to specify their own exclude and include values through the script options dialog in the Add Ons Manager.<br />
Thus, each script has its own rules plus optionally the user's rules.<br />
<br />
The user's rules are checked first, then the script's rules are checked.<br />
If any exclude matches the page, the script does not run.<br />
If any include matches the page, the script will run.<br />
If a script include matches, but a user exclude also matches, the user exclude will take precedence over the script, and it will not run.<br />
If a script exclude matches, but a user include also matches, the user include will take precedence over the script, and it will run.</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Include_and_exclude_rules&diff=7239Include and exclude rules2013-01-24T19:18:37Z<p>LouCypher: /* Greaseable schemes */ Added file: scheme and /* Notes */</p>
<hr />
<div>[[User script]]s specify include and exclude rules in the [[metadata block]].<br />
<br />
'''The script will execute if it matches any include rule, as long as it does not match an exclude rule.'''<br />
<br />
The rules are URLs, which can have a "wildcard" asterisk (*), which matches any string including the empty string. For example: <code><nowiki>http://www.example.com/foo/*</nowiki></code> will match:<br />
<br />
* <code><nowiki>http://www.example.com/foo/bar</nowiki></code> and,<br />
* <code><nowiki>http://www.example.com/foo/</nowiki></code><br />
<br />
but not:<br />
<br />
* <code><nowiki>http://www.example.com/baz/</nowiki></code>.<br />
<br />
== Globs ==<br />
<br />
Include and exclude rules support the <code>*</code> or [[wikipedia:Glob (programming)|globbing operator]].<br />
The <code>*</code> serves as a wildcard that matches one or more of any character.<br />
A rule can have several wildcards or none, in which case the rule must match the entire URL exactly.<br />
Exclude rules look the same, and prevent the script from being executed.<br />
For example:<br />
<br />
<pre class="sample"><br />
// ==UserScript==<br />
// @include <nowiki>http://www.example.com/foo/*</nowiki><br />
// @include <nowiki>http://www.example.org/*.bar</nowiki><br />
// @exclude <nowiki>http://www.example.com/foo/baz</nowiki><br />
// ==/UserScript==<br />
</pre><br />
<br />
If no include rule is provided, <code>@include *</code> is assumed.<br />
That is: every URL will be matched, within the allowed [[#Greaseable_schemes |Greaseable schemes]].<br />
<br />
== Regular Expressions ==<br />
<br />
As of [[Version_history#0.9.8|Greasemonkey 0.9.8]], support for full regular expressions in include and exclude rules was added.<br />
If the rule both starts and ends with a forward-slash (<code>/</code>) character, the contents inside those slashes are interpreted as a a regular expression.<br />
For example:<br />
<br />
<pre class="sample"><br />
// ==UserScript==<br />
// @include <nowiki>/^https?://www\.example\.com/.*$/</nowiki><br />
// @include <nowiki>/^http://www\.example\.(org|net)//</nowiki><br />
// ==/UserScript==<br />
</pre><br />
<br />
Note:<br />
* The rule is parsed as a standard javascript <code>new RegExp()</code>, so you do not need to escape forward slashes inside the rule. Special regex characters (like <code>.</code>) '''should''' still be escaped, as in the above examples; otherwise they have their normal regex meaning (like <code>.</code> matching any non-newline character).<br />
* The rule is always treated as case insensitive.<br />
* Anchors (<code>^</code>, <code>$</code>) are not supplied for you. If desired, they should be used as in the above example.<br />
<br />
== Greaseable schemes ==<br />
<br />
Greasemonkey will run scripts only on documents loaded from particular [http://en.wikipedia.org/wiki/URI_scheme schemes].<br />
By default, those are:<br />
<br />
* http<br />
* https<br />
* ftp<br />
* data<br />
* file (see [[#Notes|Notes]] #2 below)<br />
<br />
=== Notes ===<br />
# What is officially called a 'scheme' in a URL is also found in JavaScript as the <code>.protocol</code> property of any abstract <code>link</code> element such as <code>&lt;a&gt;</code>, <code>&lt;link&gt;</code>, or a DOM object such as <code>document.location</code>.<br />
# To enable Greasemonkey on <code style="background:none;">file:</code> scheme, enter <code>about:config?filter=fileIsGreaseable</code> in Location Bar. On about:config page, change <code>extensions.greasemonkey.fileIsGreaseable</code> value to <code>true</code>.<br />
<br />
== Extra schemes ==<br />
<br />
Greasemonkey will also run scripts on:<br />
<br />
; file:<br />
: Only if <code>greasemonkey.fileIsGreaseable</code> is set to <code>true</code> in [http://kb.mozillazine.org/About:config about:config].<br />
; about:<br />
: <s>Prior to 0.9.8, scripts would only run if <code>greasemonkey.aboutIsGreaseable</code> is set to <code>true</code> in [http://kb.mozillazine.org/About:config about:config]. (But about:blank is always allowed.)</s>.<br />
: Since 0.9.8, only about:blank is allowed and only when explicitly included. ({{GitTicket|1375}})<br />
<br />
In both cases this restriction is intended to prevent security/privacy vulnerabilities.<br />
<br />
== Magic TLD ==<br />
<br />
The only special syntax besides the wildcard is .tld. An include such as <code><nowiki>http://www.example.tld/*</nowiki></code> will match any top level domain, such as <code>www.example.com</code>, <code>www.example.org</code>, <code>www.example.co.uk</code>, and so on. One must be careful with this, to not accidentally leak data to a site that they did not mean to match. This list of TLDs includes myriad dual-segment TLDs (such as ca.us, aeroport.fr and kyoto.jp), beside the plain country or category codes (com, jp, se). For a full list see the [[Magic TLD]] page.<br />
<br />
== Data scheme user scripts ==<br />
<br />
Browsers can open windows in which all of the page top content is contained in a [http://en.wikipedia.org/wiki/Data_URI_scheme data scheme URI].<br />
For example, the below URI will display a HTML page that indirectly includes an image from google.com as its sole content:<br />
<br />
<nowiki>data:text/html;charset=utf-8,<html><head><title>data: test</title></head><body><img src='http://www.google.com/intl/en_ALL/images/logo.gif'></body></html></pre></nowiki><br />
<br />
[http://tinyurl.com/yl8djvy This link] points to the above data URI and can be clicked to see it in action.<br />
<br />
Firefox ignores unknown semicolon separated parameters in the header of a <code>data</code> URI (and the standards seem to leave this possibility open) which means if one adds say the string <code>MyScript;</code> in the header of the above URI, giving:<br />
<br />
data:text/html;MyScript;charset=utf-8,<html><head><title>data: test</title>....<br />
<br />
one can then use [[Include and exclude rules]] such as<br />
<br />
@include data:text/html;MyScript;*<br />
<br />
to trigger user scripts to run on a subtype of <code>data</code> URIs.<br />
<br />
This ability can be useful if a user script creates one or more <code>data</code> URIs and then opens them. Augmenting the URIs with some extra marking can cause specific user scripts to run in their windows. For example, a user script can create a <code>data URI</code> that contains a HTML <code>table</code> and trigger a user script for it that allows the user sort it.<br />
<br />
== User Specified Rules ==<br />
<br />
Since Greasemonkey [[Version history#0.9.9|0.9.9]], users have been able to specify their own exclude and include values through the script options dialog in the Add Ons Manager.<br />
Thus, each script has its own rules plus optionally the user's rules.<br />
<br />
The user's rules are checked first, then the script's rules are checked.<br />
If any exclude matches the page, the script does not run.<br />
If any include matches the page, the script will run.<br />
If a script include matches, but a user exclude also matches, the user exclude will take precedence over the script, and it will not run.<br />
If a script exclude matches, but a user include also matches, the user include will take precedence over the script, and it will run.</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Contributing_to_Greasemonkey&diff=7232Contributing to Greasemonkey2013-01-05T02:05:28Z<p>LouCypher: New section /* Documentations */</p>
<hr />
<div>See https://github.com/greasemonkey/greasemonkey<br />
<br />
== Documentations ==<br />
* [https://github.com/greasemonkey/greasemonkey/wiki Developers wiki]<br />
** [https://github.com/greasemonkey/greasemonkey/wiki/Development-Philosophy Development Philosophy]<br />
** [https://github.com/greasemonkey/greasemonkey/wiki/Ideas-Whiteboard Ideas Whiteboard]<br />
** [https://github.com/greasemonkey/greasemonkey/wiki/Test-Cases Test Cases]<br />
* [http://greasemonkey.github.com/contrib.html Contributing to Greasemonkey]<br />
* [http://greasemonkey.github.com/style.html Greasemonkey - JavaScript Style Guide]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM_config&diff=7231GM config2013-01-02T02:02:13Z<p>LouCypher: /* See also */ Replaced broken GM_config Wiki link with the working one</p>
<hr />
<div>{{DISPLAYTITLE:GM_config}}<br />
<br />
'''Note:''' This tool, despite its name, is ''not'' an official Greasemonkey [[API]].<br />
<br />
== Description ==<br />
<br />
The purpose of GM_config is to create a lightweight graphical settings dialog that can be easily used in user scripts, through <tt>@require</tt>.<br />
<br />
== Usage ==<br />
<br />
To use this tool in your script, simply include in the [[Metadata Block]], for example:<br />
<br />
<pre class='sample'>// @require http://github.com/sizzlemctwizzle/GM_config/raw/master/gm_config.js</pre><br />
<br />
For detailed usage and reference, please see the "wiki" linked below.<br />
<br />
== See also ==<br />
<br />
* [https://github.com/sizzlemctwizzle/GM_config/wiki GM_config Wiki]<br />
* [http://userscripts.org/groups/68 GM_config Dev] group at userscripts.org<br />
* [https://github.com/sizzlemctwizzle/GM_config/ Source, at github.com]<br />
<br />
[[Category:@require Library]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Multi_Line_Strings&diff=7230Multi Line Strings2013-01-02T01:17:20Z<p>LouCypher: /* Using @resource */ id est -> exempli gratia</p>
<hr />
<div>Sometimes, it is desirable to use a multi line string in JavaScript, such as when adding css styles.<br />
Here are some approaches, and discussion about the strengths and weaknesses of each approach.<br />
<br />
== Concatenation ==<br />
<br />
The basic method:<br />
<br />
<pre class='sample'><br />
var longString = "Lorem ipsum dolor sit amet, " +<br />
"venenatis penatibus etiam. " +<br />
"Nec purus cras elit nec. " +<br />
"Elit pharetra hymenaeos. " +<br />
"Donec at cubilia pulvinar elit. " +<br />
"Aliquet pretium tortor montes maecenas ante amet vel bibendum.";<br />
</pre><br />
<br />
Pros:<br />
* Simple to understand.<br />
Cons:<br />
* Extra syntax at the head and tail of every line.<br />
* JavaScript string concatenation has poor performance characteristics.<br />
<br />
A very similar but more efficient approach would define an array of many strings, then join them into one long string:<br />
<br />
<pre class='sample'><br />
var longString = ["Lorem ipsum dolor sit amet, ",<br />
"venenatis penatibus etiam. ",<br />
"Nec purus cras elit nec. ",<br />
"Elit pharetra hymenaeos. ",<br />
"Donec at cubilia pulvinar elit. ",<br />
"Aliquet pretium tortor montes maecenas ante amet vel bibendum."<br />
].join("");<br />
</pre><br />
<br />
== Line continuation ==<br />
<br />
JavaScript can continue lines, via trailing backslashes, like C:<br />
<br />
<pre class='sample'><br />
var longString = "Lorem ipsum dolor sit amet, \<br />
venenatis penatibus etiam. \<br />
Nec purus cras elit nec. \<br />
Elit pharetra hymenaeos. \<br />
Donec at cubilia pulvinar elit. \<br />
Aliquet pretium tortor montes maecenas ante amet vel bibendum.";<br />
</pre><br />
<br />
Pros:<br />
* Efficient.<br />
Cons:<br />
* An uncommon technique, therefore not as well understood.<br />
* Requires extra syntax, albeit not as much as with concatenation.<br />
<br />
== Using <tt>@resource</tt> ==<br />
<br />
If the string is too long or too big &mdash; e.g. CSS code, JSON data &mdash; you can use [[Metadata Block#@resource|<tt>@resource</tt>]] metadata in your script and get its content using [[GM_getResourceText|<tt>GM_getResourceText</tt>]] API.<br />
<br />
First, add <code>@resource</code> in metadata block<br />
<br />
<nowiki>// @resource resourceName http://www.example.com/example.ext</nowiki><br />
<br />
You can then do something like<br />
<br />
alert(GM_getResourceText("resourceName"));<br />
<br />
GM_addStyle(GM_getResourceText("resourceName")); // if resource content is CSS<br />
<br />
element.innerHTML = GM_getResourceText("resourceName"); // if resource content is HTML<br />
<br />
var data = JSON.parse(GM_getResourceText("resourceName")); // if resource content is JSON<br />
<br />
or whatever.<br />
<br />
Pros:<br />
* TBA<br />
<br />
Cons:<br />
* Requires file to be downloaded.<br />
* TBA<br />
<br />
[[Category:Coding Tips:General]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Multi_Line_Strings&diff=7229Multi Line Strings2013-01-02T01:14:26Z<p>LouCypher: /* Using @resource */</p>
<hr />
<div>Sometimes, it is desirable to use a multi line string in JavaScript, such as when adding css styles.<br />
Here are some approaches, and discussion about the strengths and weaknesses of each approach.<br />
<br />
== Concatenation ==<br />
<br />
The basic method:<br />
<br />
<pre class='sample'><br />
var longString = "Lorem ipsum dolor sit amet, " +<br />
"venenatis penatibus etiam. " +<br />
"Nec purus cras elit nec. " +<br />
"Elit pharetra hymenaeos. " +<br />
"Donec at cubilia pulvinar elit. " +<br />
"Aliquet pretium tortor montes maecenas ante amet vel bibendum.";<br />
</pre><br />
<br />
Pros:<br />
* Simple to understand.<br />
Cons:<br />
* Extra syntax at the head and tail of every line.<br />
* JavaScript string concatenation has poor performance characteristics.<br />
<br />
A very similar but more efficient approach would define an array of many strings, then join them into one long string:<br />
<br />
<pre class='sample'><br />
var longString = ["Lorem ipsum dolor sit amet, ",<br />
"venenatis penatibus etiam. ",<br />
"Nec purus cras elit nec. ",<br />
"Elit pharetra hymenaeos. ",<br />
"Donec at cubilia pulvinar elit. ",<br />
"Aliquet pretium tortor montes maecenas ante amet vel bibendum."<br />
].join("");<br />
</pre><br />
<br />
== Line continuation ==<br />
<br />
JavaScript can continue lines, via trailing backslashes, like C:<br />
<br />
<pre class='sample'><br />
var longString = "Lorem ipsum dolor sit amet, \<br />
venenatis penatibus etiam. \<br />
Nec purus cras elit nec. \<br />
Elit pharetra hymenaeos. \<br />
Donec at cubilia pulvinar elit. \<br />
Aliquet pretium tortor montes maecenas ante amet vel bibendum.";<br />
</pre><br />
<br />
Pros:<br />
* Efficient.<br />
Cons:<br />
* An uncommon technique, therefore not as well understood.<br />
* Requires extra syntax, albeit not as much as with concatenation.<br />
<br />
== Using <tt>@resource</tt> ==<br />
<br />
If the string is too long or too big &mdash; i.e. CSS code, JSON data &mdash; you can use [[Metadata Block#@resource|<tt>@resource</tt>]] metadata in your script and get its content using [[GM_getResourceText|<tt>GM_getResourceText</tt>]] API.<br />
<br />
First, add <code>@resource</code> in metadata block<br />
<br />
<nowiki>// @resource resourceName http://www.example.com/example.ext</nowiki><br />
<br />
You can then do something like<br />
<br />
alert(GM_getResourceText("resourceName"));<br />
<br />
GM_addStyle(GM_getResourceText("resourceName")); // if resource content is CSS<br />
<br />
element.innerHTML = GM_getResourceText("resourceName"); // if resource content is HTML<br />
<br />
var data = JSON.parse(GM_getResourceText("resourceName")); // if resource content is JSON<br />
<br />
or whatever.<br />
<br />
Pros:<br />
* TBA<br />
<br />
Cons:<br />
* Requires file to be downloaded.<br />
* TBA<br />
<br />
[[Category:Coding Tips:General]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Multi_Line_Strings&diff=7228Multi Line Strings2013-01-02T01:13:00Z<p>LouCypher: /* Using @resource */</p>
<hr />
<div>Sometimes, it is desirable to use a multi line string in JavaScript, such as when adding css styles.<br />
Here are some approaches, and discussion about the strengths and weaknesses of each approach.<br />
<br />
== Concatenation ==<br />
<br />
The basic method:<br />
<br />
<pre class='sample'><br />
var longString = "Lorem ipsum dolor sit amet, " +<br />
"venenatis penatibus etiam. " +<br />
"Nec purus cras elit nec. " +<br />
"Elit pharetra hymenaeos. " +<br />
"Donec at cubilia pulvinar elit. " +<br />
"Aliquet pretium tortor montes maecenas ante amet vel bibendum.";<br />
</pre><br />
<br />
Pros:<br />
* Simple to understand.<br />
Cons:<br />
* Extra syntax at the head and tail of every line.<br />
* JavaScript string concatenation has poor performance characteristics.<br />
<br />
A very similar but more efficient approach would define an array of many strings, then join them into one long string:<br />
<br />
<pre class='sample'><br />
var longString = ["Lorem ipsum dolor sit amet, ",<br />
"venenatis penatibus etiam. ",<br />
"Nec purus cras elit nec. ",<br />
"Elit pharetra hymenaeos. ",<br />
"Donec at cubilia pulvinar elit. ",<br />
"Aliquet pretium tortor montes maecenas ante amet vel bibendum."<br />
].join("");<br />
</pre><br />
<br />
== Line continuation ==<br />
<br />
JavaScript can continue lines, via trailing backslashes, like C:<br />
<br />
<pre class='sample'><br />
var longString = "Lorem ipsum dolor sit amet, \<br />
venenatis penatibus etiam. \<br />
Nec purus cras elit nec. \<br />
Elit pharetra hymenaeos. \<br />
Donec at cubilia pulvinar elit. \<br />
Aliquet pretium tortor montes maecenas ante amet vel bibendum.";<br />
</pre><br />
<br />
Pros:<br />
* Efficient.<br />
Cons:<br />
* An uncommon technique, therefore not as well understood.<br />
* Requires extra syntax, albeit not as much as with concatenation.<br />
<br />
== Using <tt>@resource</tt> ==<br />
<br />
If the string is too long &mdash; i.e. CSS code, JSON data &mdash; you can use [[Metadata Block#@resource|<tt>@resource</tt>]] metadata in your script and get its content using [[GM_getResourceText|<tt>GM_getResourceText</tt>]] API.<br />
<br />
First, add <code>@resource</code> in metadata block<br />
<br />
<nowiki>// @resource resourceName http://www.example.com/example.ext</nowiki><br />
<br />
You can then do something like<br />
<br />
alert(GM_getResourceText("resourceName"));<br />
<br />
GM_addStyle(GM_getResourceText("resourceName")); // if resource content is CSS<br />
<br />
element.innerHTML = GM_getResourceText("resourceName"); // if resource content is HTML<br />
<br />
var data = JSON.parse(GM_getResourceText("resourceName")); // if resource content is JSON<br />
<br />
or whatever.<br />
<br />
Pros:<br />
* TBA<br />
<br />
Cons:<br />
* Requires file to be downloaded.<br />
* TBA<br />
<br />
[[Category:Coding Tips:General]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Tutorials&diff=7226Tutorials2012-12-30T09:50:35Z<p>LouCypher: Undo revision 7223 by Jardrake (talk) (spam)</p>
<hr />
<div>Most of the information on this site is helpful. See the [[Greasemonkey Manual]] for starters.<br />
<br />
== Greasemonkey tutorials ==<br />
* [http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks Greasemonkey hacks] (as a wiki)<br /><br />
** includes [[Avoid Common Pitfalls in Greasemonkey]]<br />Much more up-to-date than DiG above.<br />
* [http://codebazaar.blogspot.com/2010/11/monkey-see-greasemonkey-do.html Monkey see, GreaseMonkey do!] - Video tutorial for GreaseMonkey userscript development<br />
<br />
== JavaScript tutorials ==<br />
<br />
* [https://developer.mozilla.org/en/JavaScript/Guide Mozilla's JavaScript Guide]<br />
* [http://www.tizag.com/javascriptT/ tizag's JavaScript Tutorial]<br />
* [http://www.quirksmode.org/js/contents.html JavaScript on QuirksMode]<br />
* The JavaScript Programming Language ([http://video.yahoo.com/watch/111593/1710507 part 1], [http://video.yahoo.com/watch/111594/1710553 2], [http://video.yahoo.com/watch/111595/1710607 3], [http://video.yahoo.com/watch/111596/1710658 4]) by Douglas Crockford<br />A set of videos of a wonderful lecture by this JavaScript guru.<br />
* [http://blog.morrisjohns.com/javascript_closures_for_dummies.html JavaScript Closures for Dummies]<br />
* [http://www.jibbering.com/faq/faq_notes/closures.html JavaScript Closures]<br />
<br />
== JavaScript references ==<br />
Once familiar with the language, one may notice there are many available features in JavaScript which are initially hard to remember.<br />
* [https://developer.mozilla.org/ MDC, an extensive wiki from Mozilla which details JavaScript and Firefox-unique features alike]<br />
* [https://developer.mozilla.org/en/Gecko_DOM_Reference Gecko DOM Reference]<br />
* [http://www.w3schools.com/jsref/ w3schools JS reference]<br />
<br />
== JavaScript Books ==<br />
* [http://www.oreilly.com/catalog/jscript5/ JavaScript: The Definitive Guide] is well regarded<br />
* For a modern introduction to JavaScript, check out John Resig's [http://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273 Pro JavaScript Techniques]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM.getResourceUrl&diff=7225GM.getResourceUrl2012-12-30T09:40:37Z<p>LouCypher: /* Returns */ greasemonkey-script: protocol</p>
<hr />
<div>{{DISPLAYTITLE:GM_getResourceURL}}<br />
<br />
== Description ==<br />
<br />
Given a defined [[Metadata Block#.40resource|@resource]], this method returns it as a URL.<br />
<br />
Compatibility: [[Version_history#0.8.20080609.0|Greasemonkey 0.8.0+]]<br />
<br />
== Syntax ==<br />
<br />
{{Function|GM_getResourceURL|resourceName}}<br />
<br />
=== Arguments ===<br />
<br />
; <code>resourceName</code><br />
: <code>String</code> The name provided when the [[Metadata Block#.40resource|@resource]] was defined, follow that link for valid naming restrictions.<br />
<br />
=== Returns ===<br />
<br />
<code>String</code>.<br />
greasemonkey-script:[''script uuid'']/[''resource name'']<br />
<br />
i.e.<br />
<br />
greasemonkey-script:94242686-1400-4dce-982a-090cbfef7ba1/image<br />
<br />
==== Prior to Greasemonkey 1.0 ====<br />
<br />
Returns string containing a base64 encoded <code>data:</code> URI.<br />
<br />
Note: This can be used anywhere a <code>data:</code> URI will work (E.G. <code><img></code> or <code><script></code>).<br />
This does not include <code><object></code> or <code><embed></code>.<br />
<br />
<!-- A better reference for the reason for the double encoding would be awesome. --><br />
The result is a base64 encoded URI, which is then also URI encoded, as [http://en.wikipedia.org/wiki/Base64#URL_applications suggested by Wikipedia], because of "+" and "/" characters in the base64 alphabet.<br />
Thus, for certain usage, this URI encoding may need to be removed.<br />
[http://github.com/greasemonkey/greasemonkey/issues/issue/1151]<br />
<br />
=== Raises ===<br />
<br />
Throws an <code>Error</code> when the named resource does not exist.<br />
<br />
== Examples ==<br />
<br />
<pre class='sample'><br />
// ==UserScript==<br />
// @resource logo http://www.example.com/logo.png<br />
// ==/UserScript==<br />
<br />
var img = document.createElement('img');<br />
img.src = GM_getResourceURL("logo");<br />
document.body.appendChild(img);<br />
</pre><br />
<br />
== See Also ==<br />
<br />
* [[GM_getResourceText]]<br />
<br />
[[Category:API_Reference|G]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Greasemonkey_Manual:API&diff=7224Greasemonkey Manual:API2012-12-30T09:23:39Z<p>LouCypher: /* Resources */ greasemonkey-script: protocol</p>
<hr />
<div>__NOTOC__<br />
{{Greasemonkey Manual TOC}}<br />
<br />
This section of the manual will be short and sweet.<br />
As mentioned elsewhere, [[Greasemonkey]] provides several methods in its API to enhance the power of [[user script]]s.<br />
They are listed here, with a brief description, but each separate method has its own page with more in-depth information, please continue reading there!<br />
<br />
=== Headers ===<br />
; [[Metadata Block|Metadata Block]] : Through JavaScript comments Greasemonkey has metadata which gives information about the script and provides [[Metadata Block#.40resource|resources]] and functionality to scripts.<br />
; [[GM_info]] : Exposes this information, plus a bit more, to the user script.<br />
<br />
=== Values ===<br />
; [[GM_deleteValue]] : This deletes a value from chrome that was previously set.<br />
; [[GM_getValue]] : A function intended to get stored values, see [[GM_setValue]] below.<br />
; [[GM_listValues]] : This API method retrieves an array of preference names that start with the branch's root.<br />
; [[GM_setValue]] : A function that accepts the name and value to store, persistently. This value can be retrieved later, even on a different invocation of the script, with [[GM_getValue]].<br />
<br />
=== Resources ===<br />
; [[GM_getResourceText]] : Like the previous, loads raw, plaintext from a resource.<br />
; [[GM_getResourceURL]] : A function that loads an external resource via a URL, such as an image, and returns the string containing the base64 encoded in the <code>data:</code> URL scheme. As of [[Version_history#1.0_2|Greasemonkey 1.0]], this function returns <code>greasemonkey-script:</code> scheme URL.<br />
<br />
=== Common Task Helpers ===<br />
; [[GM_addStyle]] : A function, taking one parameter, a string of CSS to apply to the page.<br />
; [[GM_xmlhttpRequest]] : A version of the XMLHttpRequest method underlying AJAX, this API call does '''not''' use the same-origin policy that a script running in a normal page is limited with, allowing complex mashups.<br />
; [[unsafeWindow]] : This object provides access to the raw JavaScript <code>window</code> scope of the content page. It is most commonly used to access JavaScript variables on the page.<br />
<br />
=== Other ===<br />
; [[GM_log]] : A function that accepts a parameter which will be routed to the Error Console, useful for examining values when writing a script.<br />
; [[GM_openInTab]] : Similar in spirit to <code>window.open()</code>, this function accepts a single parameter, the URL of a page to open in a new tab.<br />
; [[GM_registerMenuCommand]] : An advanced function which allows a user script to register a menu item, and command to run when clicked, in the Firefox user interface.<br />
<br />
[[Category:API Reference|*{{FULLPAGENAME}}]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Main_Page&diff=2555Main Page2008-04-01T19:15:05Z<p>LouCypher: Reverted edits by Pepedro to last version by Arantius</p>
<hr />
<div>__NOTOC__<br />
'''GreaseSpot''' is community documentation for [[user script]]ing with [[Greasemonkey]]. Please [[GreaseSpot:Editor portal|contribute]].<br />
<br />
== Getting Started ==<br />
Before writing a script or posting to the [[mailing list]] for help, '''every''' script writer should read Mark Pilgrim's [http://www.oreillynet.com/pub/a/network/2005/11/01/avoid-common-greasemonkey-pitfalls.html Avoid Common Pitfalls in Greasemonkey].<br />
<br />
* [[Greasemonkey Manual]]<br />
* [[Tutorials]]<br />
* [[Mailing list]]<br />
<br />
== Scripting References ==<br />
<br />
* [[API reference]]<br />
* [[Metadata block]]<br />
* [[:Category:Scripting context|Scripting context]]<br />
** [[Sandbox]]<br />
** [[Global object]]<br />
** [[XPCNativeWrapper]]<br />
** [[Scriptable content]]<br />
** [[DOMContentLoaded]]<br />
* [[Security]]<br />
** [[unsafeWindow]]<br />
<br />
== Authoring Tips ==<br />
* [[Useful Tools for Script Writers]]<br />
* [[Troubleshooting]]<br />
* [[0.7.20080121.0+ compatibility]]: Working around errors introduced by changes in Greasemonkey 0.7.20080121.0<br />
* [[Code snippets]]: useful staple functions.<br />
* [[Coding tips]]: things you might not have thought of.<br />
* [[HTML injection tips]]: how to add your html anywhere, dodging page CSS invading yours<br />
* [[:Category:Site-specific tips|Site-specific tips]]<br />
** [[:Category:Ajax site tips|Ajax site tips]]<br />
* [[Security tips]]<br />
* [[Etiquette]]<br />
* [[Cross-browser userscripting]]<br />
<br />
== Extension Development ==<br />
<br />
* [http://greasemonkey.devjavu.com/projects/greasemonkey/wiki/ContributeToGreasemonkey Contributing to Greasemonkey ]<br />
<br />
== Also ==<br />
<br />
* [[FAQ]]<br />
* [[Links]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Security&diff=1741Security2007-03-13T16:10:17Z<p>LouCypher: /* See Also */ + :Category:Security</p>
<hr />
<div>This page is a description of [[Greasemonkey]]'s security model. For tips you can apply directly to your scripts, see '''[[Security tips]]'''.<br />
<br />
= Overview =<br />
<br />
[[Version history|Historically]], [[Greasemonkey]] would inject a [[user script]] into a page by creating a <code><script></code> tag with the [[user script]] contents inline, and appending it to the content page's DOM.<br />
<br />
Mark Pilgrim originally [http://mozdev.org/pipermail/greasemonkey/2005-July/004022.html described a security flaw] with this design, on July 19th 2005, while [[Greasemonkey]] was at [[version]] 0.3.4.<br />
[[Greasemonkey]] [[version]] 0.3.5 was immediately released, with all [[API reference|GM_* functions]] disabled, to plug the security hole.<br />
''(Needed: more description of what the holes/problems were.)''<br />
<br />
To fix the security flaw, [[XPCNativeWrapper]]s, a new feature of the then-in-development Firefox 1.5, were used to isolate privileged [[user script]] code from insecure content pages.<br />
Certain other changes were made, including restrictions on the [[GM_xmlhttpRequest]] method, to disallow access to local files.<br />
<br />
= unsafeWindow =<br />
<br />
Wrapping the [[user script]] environment this way creates a [[sandbox]].<br />
This sandbox introduces many side effects and limitations.<br />
To allow maximum flexibility for [[user script]] authors, the <code>[[unsafeWindow]]</code> property was added in to the sandbox.<br />
<br />
The <code>window</code> object functions as the global scope in javascript.<br />
For [[user script]]s, this global window option is in fact a "deep wrapper" of the content window.<br />
The content window can be accessed by [[user script]]s, but only indirectly through the wrapper.<br />
The <code>unsafeWindow</code> property is a direct line to the actual content window.<br />
<br />
Use of the <code>unsafeWindow</code> property should be avoided whenever possible.<br />
Its use has the potential to open up all the original security holes that introducing the [[XPCNativeWrapper]]s fixed.<br />
When a [[user script]] relies on the <code>unsafeWindow</code> property, it should be included only on trusted pages, and even then is not guaranteed to be safe.<br />
<br />
= See Also =<br />
<br />
* [http://it.slashdot.org/article.pl?sid=05/07/19/143241 Slashdot: Firefox Greasemonkey Extension Security Problem]<br />
<br />
{{stub}}<br />
<br />
[[Category:Security|*]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Category:Security&diff=1740Category:Security2007-03-13T16:08:57Z<p>LouCypher: New category</p>
<hr />
<div><!-- --></div>LouCypherhttps://wiki.greasespot.net/index.php?title=Metadata_Block&diff=1739Metadata Block2007-03-10T13:50:16Z<p>LouCypher: /* Example */ unlinkification</p>
<hr />
<div>The '''metadata block''' is a section of a [[user script]] that does not execute any code, but describes the script. It contains the script name, namespace, description, and [[include and exclude rules]].<br />
<br />
The metadata block appears in Javascript comments. It begins with the line<br />
<br />
// == UserScript==<br />
<br />
and ends with<br />
<br />
// == /UserScript==<br />
<br />
Everything between those lines is in the format<br />
<br />
// @<var>key</var> <var>value</var><br />
<br />
If the metadata block includes a key that Greasemonkey does not understand, it will simply be ignored.<br />
<br />
== Metadata keys ==<br />
<br />
=== @name ===<br />
<br />
The name of the script. This appears in the [[script manager]] and [[monkey menu]], and is also used to determine whether to overwrite an old version of a script or to install it separately. If no name is provided, it will be inferred from the file name.<br />
<br />
=== @namespace ===<br />
<br />
The namespace, along with the name, is used to determine whether to overwrite an old version of a script or to install it separately. A script author will usually put all of their scripts under one common namespace, and then assign each script a unique name. If two scripts have the same name, but a different namespace, they can co-exist. However, two scripts of the same name in the same namespace are assumed to be replacements for one another. While the namespace is non-semantic, it should be a URI. If no namespace is provided, it is assumed to be the domain from which the script is installed. Since a script can live on various servers or on a local file system, authors should specify this.<br />
<br />
=== @description ===<br />
<br />
Just a description.<br />
<br />
=== @include and @exclude ===<br />
<br />
Refer to ''[[Include and exclude rules]]''. There can be any number of @include and @exclude rules in a script.<br />
<br />
== Example ==<br />
<br />
// ==UserScript==<br />
// @name My Script<br />
// @namespace <nowiki>http://www.example.com/gmscripts/</nowiki><br />
// @description Scripting is fun<br />
// @include <nowiki>http://www.example.com/*</nowiki><br />
// @include <nowiki>http://www.example.org/*</nowiki><br />
// @exclude <nowiki>http://www.example.org/foo</nowiki><br />
// ==/UserScript==<br />
<br />
== Other Keys ==<br />
<br />
Some [[user script]]s contain other keys in the metadata block.<br />
Common keys are <code>@author</code>, <code>@version</code>, or <code>@homepage</code>.<br />
These metadata keys serve no technical purpose.<br />
They are ignored by [[Greasemonkey]], but they can be read by human beings.<br />
<br />
== Caveats ==<br />
<br />
Changing the metadata of an installed script does not do anything, as this data is only accessed during installation. The script must be re-installed for these changes to take. Alternatively, [[config.xml]] can be modified manually.</div>LouCypherhttps://wiki.greasespot.net/index.php?title=User:LouCypher&diff=1729User:LouCypher2007-02-26T21:43:14Z<p>LouCypher: /* User scripts */</p>
<hr />
<div>== User scripts==<br />
* [http://userscripts.org/users/12;scripts userscripts.org/users/12;scripts]<br />
* [http://zoolcar9.lhukie.net/mozilla/userscripts/ zoolcar9.lhukie.net/mozilla/userscripts/]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Sandbox&diff=1686Sandbox2007-01-24T00:51:24Z<p>LouCypher: fix interwiki link</p>
<hr />
<div>For [[security]] reasons, modern [[Version history|versions]] of [[Greasemonkey]] execute each script in a "sandbox", which isolates trusted [[user script]] code from potentially malicious web page code.<br />
<br />
Documentation for Component.utils.Sandbox may eventually show up on the [http://developer.mozilla.org/en/docs/Components.utils Component.utils] page, but it not there now. There is documentation for [http://developer.mozilla.org/en/docs/Components.utils.evalInSandbox Components.utils.evalInSandbox] which gives an example of Sandbox usage.<br />
<br />
For more information, see [[Wikipedia:Sandbox_(computer_security)|wikipedia's article on the topic]].<br />
<br />
{{stub}}</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Include_and_exclude_rules&diff=1660Include and exclude rules2006-12-14T17:53:27Z<p>LouCypher: add code tags, unlinkify example URLs</p>
<hr />
<div>[[User script]]s specify include and exclude rules in the [[metadata block]]. The script will execute if it matches any include rule, as long as it does not match an exclude rule. The rules are URLs, which can have a "wildcard" asterisk (*), which matches any string. For example: <code><nowiki>http://www.example.com/foo/*</nowiki></code> will match <code><nowiki>http://www.example.com/foo/bar</nowiki></code> and <code><nowiki>http://www.example.com/foo/</nowiki></code>, but not <code><nowiki>http://www.example.com/baz/</nowiki></code>. A rule can have several wildcards or none, in which case the rule must match the entire URL exactly. Exclude rules look the same, and prevent the script from being executed. An example:<br />
<br />
// ==UserScript==<br />
// @include <nowiki>http://www.example.com/foo/*</nowiki><br />
// @include <nowiki>http://www.example.org/*.bar</nowiki><br />
// @exclude <nowiki>http://www.example.com/foo/baz</nowiki><br />
// ==/UserScript==<br />
<br />
If no include rule is provided, <code>@include *</code> is assumed. That is, every URL will be matched.<br />
<br />
== Magic TLD ==<br />
<br />
The only special syntax besides the wildcard is .tld. An include such as <code><nowiki>http://www.example.tld/*</nowiki></code> will match any top level domain, such as <code>www.example.com</code>, <code>www.example.org</code>, <code>www.example.net</code>, and so on. One must be careful with this, to not accidentally leak data to a site that they did not mean to match.<br />
<br />
The following is a pseudo-code representation of the code that performs the regular expression searching in Greasemonkey that supports the TLD special function. The actual Javascript code is located in the extension convert2RegExp.js file.<br />
<br />
Key:<br />
<code><br />
. = actual required period character<br />
* = any character<br />
! = any character not a period<br />
[] = optional<br />
() = parenthetical grouping<br />
AND = logical And<br />
OR = logical Or<br />
, = logical Or<br />
<br />
Note that some "AND's" are implied, and Space characters are ignored.<br />
</code><br />
Pseudo-code:<br />
<code><br />
* AND<br />
(<br />
demon.co.uk<br />
OR<br />
esc.edu.ar<br />
OR ( [ co. OR ci. ] !. AND<br />
( vt.us, ne.us, ks.us, il.us, hi.us, sc.us, nh.us, ia.us, wy.us, or.us,<br />
ma.us, vi.us, tn.us, in.us, az.us, id.us, nc.us, co.us, dc.us, nd.us,<br />
me.us, al.us, ak.us, de.us, wv.us, nm.us, mo.us, pr.us, nj.us, sd.us,<br />
md.us, va.us, ri.us, ut.us, ct.us, pa.us, ok.us, ky.us, mt.us, ga.us,<br />
la.us, oh.us, ms.us, wi.us, wa.us, gu.us, mi.us, tx.us, fl.us, ca.us,<br />
ar.us, mn.us, ny.us, nv.us ) )<br />
OR<br />
!. [pvt.] ( k12., cc., tec., lib., state., gen. ) . AND<br />
( vt.us, ne.us, ks.us, il.us, hi.us, sc.us, nh.us, ia.us, wy.us, or.us,<br />
ma.us, vi.us, tn.us, in.us, az.us, id.us, nc.us, co.us, dc.us, nd.us,<br />
me.us, al.us, ak.us, de.us, wv.us, nm.us, mo.us, pr.us, nj.us, sd.us,<br />
md.us, va.us, ri.us, ut.us, ct.us, pa.us, ok.us, ky.us, mt.us, ga.us,<br />
la.us, oh.us, ms.us, wi.us, wa.us, gu.us, mi.us, tx.us, fl.us, ca.us,<br />
ar.us, mn.us, ny.us, nv.us )<br />
OR<br />
!. (2000.hu, ab.ca, ac, ac.ae, ac.at, ac.be, ac.cn, ac.cr, ac.cy, ac.fj,<br />
ac.fk, ac.gg, ac.id, ac.il, ac.im, ac.in, ac.je, ac.jp, ac.kr, ac.ma,<br />
ac.ng, ac.nz, ac.om, ac.pa, ac.pg, ac.th, ac.ug, ac.uk, ac.vn, ac.yu,<br />
ac.za, ac.zw, ad, ad.jp, ae, aero, aeroport.fr, af, ag, agrar.hu,<br />
agro.pl, ah.cn, ai, aichi.jp, aid.pl, ak, akita.jp, al, al, alderney.gg,<br />
alt.na, alt.za, am, an, ao, aomori.jp, aq, ar, ar, arpa, art.br, art.do,<br />
art.dz, arts.co, arts.ve, as, asn.au, asn.lv, ass.dz, assedic.fr,<br />
asso.fr, asso.re, at, at.tt, atm.pl, au, au.com, au.tt, auto.pl,<br />
avocat.fr, avoues.fr, aw, ax, az, az, ba, barreau.fr, bb, bbs.tr, bc.ca,<br />
bd, be, be.tt, belgie.be, bf, bg, bh, bi, bib.ve, biz, biz.et, biz.om,<br />
biz.pk, biz.pl, biz.tt, biz.vn, bj, bj.cn, bm, bn, bo, bolt.hu,<br />
bourse.za, br, br.com, bs, bt, bv, bw, by, bz, ca, ca, ca.tt, casino.hu,<br />
cc, cci.fr, cd, cf, cg, ch, ch.vu, chambagri.fr, chiba.jp,<br />
chirurgiens-dentistes.fr, ci, city.hu, city.za, ck, cl, cm, cn, cn.com,<br />
co, co, co.ae, co.at, co.ck, co.cr, co.dk, co.gg, co.hu, co.id, co.il,<br />
co.im, co.in, co.je, co.jp, co.kr, co.ma, co.nz, co.om, co.th, co.tt,<br />
co.tv, co.ug, co.uk, co.ve, co.vi, co.yu, co.za, co.zw, com, com.ac,<br />
com.ae, com.ai, com.ar, com.au, com.az, com.bb, com.bh, com.bm, com.br,<br />
com.bs, com.cn, com.co, com.cu, com.cy, com.do, com.dz, com.ec, com.eg,<br />
com.et, com.fj, com.fk, com.fr, com.ge, com.gu, com.hk, com.jo, com.kh,<br />
com.kw, com.la, com.lb, com.lc, com.lv, com.ly, com.mk, com.mm, com.mo,<br />
com.mt, com.mx, com.my, com.na, com.nc, com.ng, com.ni, com.np, com.om,<br />
com.pa, com.pe, com.pg, com.ph, com.pk, com.pl, com.py, com.qa, com.re,<br />
com.ru, com.sa, com.sb, com.sd, com.sg, com.sh, com.sv, com.sy, com.tn,<br />
com.tr, com.tt, com.tw, com.ua, com.uy, com.ve, com.vn, com.vu, com.ws,<br />
com.ye, conf.au, conf.lv, coop, cq.cn, cr, cri.nz, cs, csiro.au, ct, cu,<br />
cul.na, cv, cx, cy, cz, dc, de, de, de.com, de.net, de.tt, de.vu, dj,<br />
dk, dk.org, dk.tt, dm, dni.us, dns.be, do, dz, e164.arpa, ec, ed.cr,<br />
ed.jp, edu, edu.ac, edu.ai, edu.ar, edu.au, edu.bh, edu.bm, edu.ck,<br />
edu.cn, edu.co, edu.do, edu.dz, edu.ec, edu.eg, edu.et, edu.ge, edu.gu,<br />
edu.hk, edu.jo, edu.kh, edu.kw, edu.lb, edu.lc, edu.lv, edu.mm, edu.mo,<br />
edu.mt, edu.my, edu.na, edu.ng, edu.ni, edu.np, edu.om, edu.pa, edu.pe,<br />
edu.pk, edu.pl, edu.ps, edu.py, edu.qa, edu.sa, edu.sb, edu.sd, edu.sg,<br />
edu.sh, edu.sv, edu.tr, edu.tt, edu.tw, edu.ua, edu.uk, edu.uy, edu.ve,<br />
edu.vn, edu.vu, edu.ws, edu.ye, edu.yu, edu.za, edunet.tn, ee, eg, eh,<br />
ehime.jp, ens.tn, er, ernet.in, erotica.hu, erotika.hu, es, es.tt, et,<br />
etc.br, eu, eu.com, eu.org, eu.tt, eun.eg, experts-comptables.fr,<br />
fam.pk, fax.nr, fed.us, fgov.be, fi, fi.cr, film.hu, fin.ec, fin.tn,<br />
firm.co, firm.in, firm.ve, fj, fk, fl, fm, fo, forum.hu, fr, fr.tt,<br />
fr.vu, fukui.jp, fukuoka.jp, fukushima.jp, g12.br, ga, ga, games.hu, gb,<br />
gb.com, gb.net, gd, gd.cn, ge, geek.nz, gen.in, gen.nz, gen.tr,<br />
geometre-expert.fr, gf, gg, gh, gi, gifu.jp, gl, gm, gmina.pl, gn,<br />
go.cr, go.id, go.jp, go.kr, go.th, go.ug, gob.ni, gob.pa, gob.pe,<br />
gob.pk, gob.sv, gok.pk, gon.pk, gop.pk, gos.pk, gouv.fr, gov, gov.ac,<br />
gov.ae, gov.ai, gov.ar, gov.au, gov.bh, gov.bm, gov.br, gov.ck, gov.cn,<br />
gov.co, gov.cy, gov.do, gov.dz, gov.ec, gov.eg, gov.et, gov.fj, gov.fk,<br />
gov.ge, gov.gg, gov.gu, gov.hk, gov.il, gov.im, gov.in, gov.je, gov.jo,<br />
gov.jp, gov.kh, gov.kw, gov.lb, gov.lc, gov.lv, gov.mm, gov.mo, gov.my,<br />
gov.ng, gov.np, gov.om, gov.pk, gov.ps, gov.qa, gov.sa, gov.sb, gov.sd,<br />
gov.sg, gov.sh, gov.sy, gov.tn, gov.tr, gov.tt, gov.ua, gov.uk, gov.ve,<br />
gov.vn, gov.ws, gov.ye, gov.za, gov.zw, gove.tw, govt.nz, gp, gq, gr,<br />
gr.jp, greta.fr, gs, gs.cn, gsm.pl, gt, gu, gu, gub.uy, guernsey.gg,<br />
gunma.jp, gv.at, gw, gx.cn, gy, gz.cn, hb.cn, he.cn, health.vn, hi,<br />
hi.cn, hiroshima.jp, hk, hk.cn, hl.cn, hm, hn, hn.cn, hokkaido.jp,<br />
hotel.hu, hr, ht, hu, hu.com, huissier-justice.fr, hyogo.jp, ia,<br />
ibaraki.jp, id, id, id.au, id.fj, id.lv, idf.il, idv.hk, idv.tw, ie, il,<br />
il, im, in, in, ind.br, ind.gg, ind.in, ind.je, ind.tn, inf.br, info,<br />
info.au, info.co, info.et, info.hu, info.pl, info.tn, info.tt, info.ve,<br />
info.vn, ingatlan.hu, int, int.ar, int.co, int.ve, int.vn, intl.tn, io,<br />
iq, ir, is, ishikawa.jp, it, it.tt, iwate.jp, iwi.nz, je, jersey.je,<br />
jl.cn, jm, jo, jobs, jogasz.hu, jp, js.cn, k12.ec, k12.il, k12.tr,<br />
kagawa.jp, kagoshima.jp, kanagawa.jp, kanazawa.jp, kawasaki.jp, ke, kg,<br />
kh, ki, kitakyushu.jp, km, kn, kobe.jp, kochi.jp, konyvelo.hu, kp, kr,<br />
ks, kumamoto.jp, kw, ky, ky, kyonggi.kr, kyoto.jp, kz, la, la, lakas.hu,<br />
law.za, lb, lc, lg.jp, li, lk, lkd.co.im, ln.cn, lr, ls, lt, ltd.gg,<br />
ltd.je, ltd.uk, lu, lv, ly, ma, ma, mail.pl, maori.nz, matsuyama.jp,<br />
mb.ca, mc, md, md, me, me.uk, med.ec, med.om, med.sa, med.sd,<br />
medecin.fr, media.hu, media.pl, mg, mh, mi, miasta.pl, mie.jp, mil,<br />
mil.ac, mil.ar, mil.br, mil.co, mil.do, mil.ec, mil.ge, mil.gu, mil.id,<br />
mil.in, mil.jo, mil.kh, mil.lb, mil.lv, mil.nz, mil.pe, mil.ph, mil.pl,<br />
mil.sh, mil.tr, mil.uy, mil.ve, mil.ye, mil.za, miyagi.jp, miyazaki.jp,<br />
mk, ml, mm, mn, mn, mo, mo, mo.cn, mob.nr, mobil.nr, mobile.nr, mod.om,<br />
mod.uk, mp, mq, mr, ms, ms, mt, mt, mu, muni.il, museum, museum.om, mv,<br />
mw, mx, my, mz, na, nagano.jp, nagasaki.jp, nagoya.jp, name, name.et,<br />
name.tt, name.vn, nara.jp, nat.tn, nb.ca, nc, nc, nd, ne, ne, ne.jp,<br />
ne.kr, net, net.ac, net.ae, net.ar, net.au, net.az, net.bb, net.bh,<br />
net.bm, net.br, net.bs, net.ck, net.cn, net.cu, net.cy, net.do, net.dz,<br />
net.ec, net.eg, net.et, net.fk, net.ge, net.gg, net.gu, net.hk, net.id,<br />
net.il, net.im, net.in, net.je, net.jo, net.jp, net.kh, net.kw, net.la,<br />
net.lb, net.lc, net.lv, net.ly, net.ma, net.mm, net.mo, net.mt, net.mx,<br />
net.my, net.na, net.nc, net.ng, net.ni, net.np, net.nz, net.om, net.pa,<br />
net.pe, net.pg, net.ph, net.pk, net.pl, net.py, net.qa, net.ru, net.sa,<br />
net.sb, net.sd, net.sg, net.sh, net.sy, net.th, net.tn, net.tr, net.tt,<br />
net.tw, net.ua, net.uk, net.uy, net.ve, net.vi, net.vn, net.vu, net.ws,<br />
net.ye, net.za, news.hu, nf, nf.ca, ng, ngo.ph, ngo.za, nh, nhs.uk, ni,<br />
nic.im, nic.in, nic.tt, nic.uk, nieruchomosci.pl, niigata.jp, nj, nl,<br />
nl.ca, nm, nm.cn, no, no.com, nom.co, nom.fk, nom.fr, nom.ni, nom.pe,<br />
nom.pl, nom.re, nom.ve, nom.za, notaires.fr, np, nr, ns.ca, nt.ca, nu,<br />
nu.ca, nvus, nx.cn, ny, nz, oh, oita.jp, ok, okayama.jp, okinawa.jp,<br />
om, on.ca, or, or.at, or.cr, or.id, or.jp, or.kr, or.th, or.ug, org,<br />
org.ac, org.ae, org.ai, org.ar, org.au, org.az, org.bb, org.bh, org.bm,<br />
org.br, org.bs, org.ck, org.cn, org.co, org.cu, org.cy, org.do, org.dz,<br />
org.ec, org.eg, org.et, org.fj, org.fk, org.ge, org.gg, org.gu, org.hk,<br />
org.hu, org.il, org.im, org.in, org.je, org.jo, org.jp, org.kh, org.kw,<br />
org.la, org.lb, org.lc, org.lv, org.ly, org.ma, org.mm, org.mo, org.mt,<br />
org.mx, org.my, org.na, org.nc, org.ng, org.ni, org.np, org.nz, org.om,<br />
org.pa, org.pe, org.ph, org.pk, org.pl, org.py, org.qa, org.ru, org.sa,<br />
org.sb, org.sd, org.sg, org.sh, org.sv, org.sy, org.tn, org.tr, org.tt,<br />
org.tw, org.ua, org.uk, org.uy, org.ve, org.vi, org.vn, org.vu, org.ws,<br />
org.ye, org.yu, org.za, org.zw, osaka.jp, otc.au, oz.au, pa, pa, pc.pl,<br />
pe, pe.ca, pe.kr, per.kh, per.sg, pf, pg, ph, pharmacien.fr, pk, pl,<br />
plc.co.im, plc.uk, plo.ps, pm, pn, pol.dz, police.uk, port.fr,<br />
powiat.pl, pp.ru, pr, pr, prd.fr, press.ma, presse.fr, priv.at, priv.hu,<br />
priv.pl, pro, pro.ae, pro.om, pro.tt, pro.vn, ps, psi.br, pt, pub.sa,<br />
pvt.ge, pw, py, qa, qc.ca, qc.com, qh.cn, re, re.kr, realestate.pl,<br />
rec.br, rec.co, rec.ve, red.sv, reklam.hu, rel.pl, res.in, ri, rnrt.tn,<br />
rns.tn, rnu.tn, ro, ru, ru.com, rw, sa, sa.com, sa.cr, saga.jp,<br />
saitama.jp, sapporo.jp, sark.gg, sb, sc, sc, sc.cn, sch.ae, sch.gg,<br />
sch.je, sch.ng, sch.sa, sch.sd, sch.uk, school.fj, school.nz, school.za,<br />
sci.eg, sd, sd, se, se.com, se.tt, sec.ps, sendai.jp, seoul.kr, sex.hu,<br />
sex.pl, sg, sh, sh.cn, shiga.jp, shimane.jp, shizuoka.jp, shop.hu,<br />
shop.pl, si, sj, sk, sk.ca, sklep.pl, sl, sld.pa, sm, sn, sn.cn, so,<br />
sos.pl, sp.br, sport.hu, sr, st, store.co, store.ve, su, suli.hu, sv,<br />
sx.cn, sy, sz, szex.hu, szkola.pl, takamatsu.jp, targi.pl, tc, td,<br />
tec.ve, tel.no, tel.nr, telecom.na, telememo.au, tf, tg, th, tj, tj.cn,<br />
tk, tl, tlf.nr, tm, tm.fr, tm.hu, tm.mt, tm.pl, tm.za, tmp.br, tn, to,<br />
tochigi.jp, tokushima.jp, tokyo.jp, tottori.jp, tourism.pl, tourism.tn,<br />
toyama.jp, tozsde.hu, tp, tr, travel, travel.pl, tt, turystyka.pl, tv,<br />
tw, tw.cn, tx, tz, ua, uba.ar, ug, uk, uk.com, uk.net, uk.tt, um,<br />
unam.na, us, us.com, us.tt, ut, utazas.hu, utsunomiya.jp, uu.mt, uy,<br />
uy.com, uz, va, va, vc, ve, veterinaire.fr, vg, vi, vi, video.hu, vn,<br />
vt, vu, wa, wakayama.jp, web.co, web.do, web.pk, web.ve, web.za, wf, wi,<br />
ws, wv, wy, xj.cn, xxx, xz.cn, yamagata.jp, yamaguchi.jp, yamanashi.jp,<br />
ye, yk.ca, yn.cn, yokohama.jp, yt, yu, za, za.com, zj.cn, zm, zw )<br />
)<br />
</code></div>LouCypherhttps://wiki.greasespot.net/index.php?title=Talk:Links&diff=1659Talk:Links2006-12-14T17:46:58Z<p>LouCypher: </p>
<hr />
<div>Seems like a bad idea to link to http://www.letitblog.com/greasemonkey-compiler/<br />
given that it won't work for virtually any browser in use today; relies on the old insecure injection method; doesn't support any GM_ apis.<br />
<br />
Any votes against removing it?<br />
<br />
: Go ahead. Firefox 1.0 is obsolete. If anything, [[compiled script]]s can get their own wiki page, with a historical mention of the original compiler. --[[User:Ldrhcp|Ldrhcp]] 20:01, 12 December 2006 (EST)<br />
::You have a point here. I removed it from the list. --[[User:LouCypher|LouCypher]] 12:46, 14 December 2006 (EST)</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Links&diff=1658Links2006-12-14T17:41:24Z<p>LouCypher: /* Tools */ remove old compiler</p>
<hr />
<div>__NOTOC__<br />
* [http://greasemonkey.mozdev.org/ Home page]<br />
* [http://greaseblog.blogspot.com/ Blog]<br />
* [https://addons.mozilla.org/firefox/748/ Mozilla Addons page]<br />
<br />
==Discussions==<br />
* [http://groups.google.com/group/greasemonkey-users Mailing list (users, scripters)]<br />
* [http://groups.google.com/group/greasemonkey-dev Mailing list (extension developers)]<br />
* [http://mozdev.org/pipermail/greasemonkey/ Old mailing list archives]<br />
<br />
==References==<br />
* [http://diveintogreasemonkey.org/ Dive Into Greasemonkey]<br />
* [http://www.oreilly.com/catalog/greasemonkeyhks/index.html?CMP=ILL-4GV796923290 Greasemonkey Hacks]<br />
* [http://www.oreillynet.com/pub/a/network/2005/11/01/avoid-common-greasemonkey-pitfalls.html Avoid Common Pitfalls in Greasemonkey]<br />
<br />
==User scripts==<br />
* [http://userscripts.org/ UserScripts.org]<br />
* [http://dunck.us/collab/GreaseMonkeyUserScripts GreaseMonkeyUserScripts] wiki<br />
<br />
==Tools==<br />
* [http://www.arantius.com/misc/greasemonkey/script-compiler.php Greasemonkey compiler] - for Firefox 1.5 and above<br />
* [http://www.squarefree.com/jsenv/ JavaScript Development Environment]<br />
* [http://software.hixie.ch/utilities/cgi/data/data The data:URI kitchen]<br />
* [https://addons.mozilla.org/firefox/737/ Platypus] - a Firefox extension which lets you modify a Web page from your browser and save the changes as a Greasemonkey script</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Links&diff=1653Links2006-12-06T04:08:48Z<p>LouCypher: /* Tools */ add Platypus</p>
<hr />
<div>__NOTOC__<br />
* [http://greasemonkey.mozdev.org/ Home page]<br />
* [http://greaseblog.blogspot.com/ Blog]<br />
* [https://addons.mozilla.org/firefox/748/ Mozilla Addons page]<br />
<br />
==Discussions==<br />
* [http://groups.google.com/group/greasemonkey-users Mailing list (users, scripters)]<br />
* [http://groups.google.com/group/greasemonkey-dev Mailing list (extension developers)]<br />
* [http://mozdev.org/pipermail/greasemonkey/ Old mailing list archives]<br />
<br />
==References==<br />
* [http://diveintogreasemonkey.org/ Dive Into Greasemonkey]<br />
* [http://www.oreilly.com/catalog/greasemonkeyhks/index.html?CMP=ILL-4GV796923290 Greasemonkey Hacks]<br />
* [http://www.oreillynet.com/pub/a/network/2005/11/01/avoid-common-greasemonkey-pitfalls.html Avoid Common Pitfalls in Greasemonkey]<br />
<br />
==User scripts==<br />
* [http://userscripts.org/ UserScripts.org]<br />
* [http://dunck.us/collab/GreaseMonkeyUserScripts GreaseMonkeyUserScripts] wiki<br />
<br />
==Tools==<br />
* [http://www.letitblog.com/greasemonkey-compiler/ Greasemonkey compiler] - for Firefox 1.0<br />
* [http://www.arantius.com/misc/greasemonkey/script-compiler.php Greasemonkey compiler] - for Firefox 1.5 and above<br />
* [http://www.squarefree.com/jsenv/ JavaScript Development Environment]<br />
* [http://software.hixie.ch/utilities/cgi/data/data The data:URI kitchen]<br />
* [https://addons.mozilla.org/firefox/737/ Platypus] - a Firefox extension which lets you modify a Web page from your browser and save the changes as a Greasemonkey script</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Links&diff=1652Links2006-12-06T04:01:40Z<p>LouCypher: add some links + organize by section</p>
<hr />
<div>__NOTOC__<br />
* [http://greasemonkey.mozdev.org/ Home page]<br />
* [http://greaseblog.blogspot.com/ Blog]<br />
* [https://addons.mozilla.org/firefox/748/ Mozilla Addons page]<br />
<br />
==Discussions==<br />
* [http://groups.google.com/group/greasemonkey-users Mailing list (users, scripters)]<br />
* [http://groups.google.com/group/greasemonkey-dev Mailing list (extension developers)]<br />
* [http://mozdev.org/pipermail/greasemonkey/ Old mailing list archives]<br />
<br />
==References==<br />
* [http://diveintogreasemonkey.org/ Dive Into Greasemonkey]<br />
* [http://www.oreilly.com/catalog/greasemonkeyhks/index.html?CMP=ILL-4GV796923290 Greasemonkey Hacks]<br />
* [http://www.oreillynet.com/pub/a/network/2005/11/01/avoid-common-greasemonkey-pitfalls.html Avoid Common Pitfalls in Greasemonkey]<br />
<br />
==User scripts==<br />
* [http://userscripts.org/ UserScripts.org]<br />
* [http://dunck.us/collab/GreaseMonkeyUserScripts GreaseMonkeyUserScripts] wiki<br />
<br />
==Tools==<br />
* [http://www.letitblog.com/greasemonkey-compiler/ Greasemonkey compiler] - for Firefox 1.0<br />
* [http://www.arantius.com/misc/greasemonkey/script-compiler.php Greasemonkey compiler] - for Firefox 1.5 and above<br />
* [http://www.squarefree.com/jsenv/ JavaScript Development Environment]<br />
* [http://software.hixie.ch/utilities/cgi/data/data The data:URI kitchen]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=User:LouCypher&diff=1651User:LouCypher2006-12-06T03:40:11Z<p>LouCypher: /* User scripts */</p>
<hr />
<div>== User scripts==<br />
* [http://userstyles.org/people/12 userstyles.org/people/12]<br />
* [http://zoolcar9.lhukie.net/mozilla/userscripts/ zoolcar9.lhukie.net/mozilla/userscripts/]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=UnsafeWindow&diff=1650UnsafeWindow2006-12-06T03:34:29Z<p>LouCypher: categorized</p>
<hr />
<div>{{lowercase}}<br />
<br />
{{security}}<br />
<br />
= Syntax =<br />
<br />
'''unsafeWindow'''<br />
<br />
= Description =<br />
<br />
[[User script]]s can use this object to access "custom" properties--variable and functions defined in the page--set by the web page. This is done by bypassing [[Greasemonkey]]'s [[XPCNativeWrapper]]-based [[security]] model. unsafeWindow is shorthand for window.wrappedJSObject; it is the raw window object inside the XPCNativeWrapper provided by the Greasemonkey [[sandbox]].<br />
<br />
unsafeWindow is insecure, and should be avoided when possible. User scripts absolutely should not use unsafeWindow if they are executed for arbitrary web pages, such as those with <code>@[[include]] *</code>.<br />
<br />
= Examples =<br />
<br />
unsafeWindow.document.title="Testing"<br />
<br />
unsafeWindow.TestVarCreatedByDocument="Testing"<br />
<br />
unsafeWindow.document.TestFunction("Test")<br />
<br />
= Alternatives to unsafeWindow =<br />
<br />
If a user script must execute a page function, it can use the '''location hack''' to call it safely. This involves setting location.href to a <code>javascript:</code> URL, which is like using a bookmarklet. For example:<br />
<br />
location.href = 'javascript:void(pageFunc(123));';<br />
<br />
Larger blocks of code can also be executed this way:<br />
<br />
location.href = 'javascript:(' + encodeURI(uneval(function() {<br />
// some code<br />
})) + ')();';<br />
<br />
This code will run in the page context without leaking the [[sandbox]]. This code is completely separate from the rest of the script scope, sometimes limiting its usefulness. For example, data cannot be returned by the function.<br />
<br />
Another drawback is that this technique is rather ugly. Still, it is preferred over unsafeWindow.<br />
<br />
<br />
[[Category:API Reference|U]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM.xmlHttpRequest&diff=1649GM.xmlHttpRequest2006-12-06T03:33:54Z<p>LouCypher: categorized</p>
<hr />
<div>{{underscore|title=GM_xmlhttpRequest}}<br />
<br />
= Syntax =<br />
<br />
'''GM_xmlhttpRequest(''' ''details'' ''')'''<br />
<br />
= Description =<br />
<br />
This API provides access to the chrome-privileged [http://kb.mozillazine.org/XMLHttpRequest XMLHttpRequest] object.<br />
This means that it '''is''' possible to issue requests to domains other than that of the current page.<br />
<br />
The details parameter is an object having the following fields: method, url, headers, onload, onreadystatechange, onerror, data.<br />
All fields are optional except method and url.<br />
The headers field is an object which should contain the name-value pairs of the headers to send, for instance {"User-Agent":"Mozilla"}.<br />
The onload, onreadystatechange, and onerror parameters are callback functions which are called when the corresponding events occur.<br />
<br />
Callback functions should accept a single object parameter having the following fields: responseText, status, statusText, readyState, and responseHeaders.<br />
The responseHeaders is the string representation of response headers returned by <code>XMLHTTPRequest.getAllResponseHeaders()</code>.<br />
<br />
= Examples =<br />
<br />
GM_xmlhttpRequest({<br />
method:"GET",<br />
url:"<nowiki>http://youngpup.net/</nowiki>",<br />
headers:{<br />
"User-Agent":"monkeyagent",<br />
"Accept":"text/monkey,text/xml",<br />
},<br />
onload:function(details) {<br />
alert([<br />
details.status,<br />
details.statusText,<br />
details.readyState,<br />
details.responseHeaders,<br />
details.responseText<br />
].join("\n"))<br />
}<br />
});<br />
<br />
= Notes =<br />
<br />
Some users have reported problems with international character sets.<br />
See these [[mailing list]] threads<br />
<br />
* http://www.mozdev.org/pipermail/greasemonkey/2006-June/008785.html<br />
* http://www.mozdev.org/pipermail/greasemonkey/2006-April/008064.html<br />
<br />
<br />
[[Category:API Reference|X]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM.registerMenuCommand&diff=1648GM.registerMenuCommand2006-12-06T03:33:13Z<p>LouCypher: categorized</p>
<hr />
<div>{{underscore|title=GM_registerMenuCommand}}<br />
<br />
= Syntax =<br />
<br />
'''GM_registerMenuCommand(''' ''commandName'', ''commandFunc'', ''accelKey'', ''accelModifiers'', ''accessKey'' ''')'''<br />
<br />
= Description =<br />
<br />
Userscripts can call GM_registerMenuCommand to add a menu command to the "User Script Commands" submenu.<br />
The first two arguments are required; the others are optional.<br />
<br />
; commandName : Name to display in the menu<br />
; commandFunc : Function to call<br />
; accelKey : A single character (e.g. 'g') or keycode that can trigger the command<br />
; accelModifiers: A string listing modifiers that must be pressed with the accelKey. If there's more than one, then they should be separated with spaces. For example, <code>'shift'</code> or <code>'ctrl alt'</code>. Available modifiers are: shift, alt, meta, control, and accel.<br />
; accessKey : A single character (e.g. 'g') that can be used to jump to the command when the menu is open. It should be a letter in commandName<br />
<br />
= Examples =<br />
<br />
GM_registerMenuCommand( "Hello world!", hello, "e", "control", "h" );<br />
<br />
GM_registerMenuCommand( "Hello world! (again)", hello2, "e", "shift alt", "w" );<br />
<br />
GM_registerMenuCommand( "Hello world (simple)", helloSimple );<br />
<br />
<br />
[[Category:API Reference|R]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM.openInTab&diff=1647GM.openInTab2006-12-06T03:32:19Z<p>LouCypher: categorized + removed link from example code</p>
<hr />
<div>{{underscore|title=GM_openInTab}}<br />
<br />
= Syntax =<br />
<br />
'''GM_openInTab(''' ''url'' ''')'''<br />
<br />
= Description =<br />
<br />
Opens the specified URL in a new tab.<br />
<br />
= Examples =<br />
<br />
GM_openInTab("<nowiki>http://greasemonkey.mozdev.org/</nowiki>");<br />
<br />
<br />
[[Category:API Reference|O]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM_log&diff=1646GM log2006-12-06T03:31:09Z<p>LouCypher: categorized</p>
<hr />
<div>{{underscore|title=GM_log}}<br />
<br />
= Syntax =<br />
<br />
'''GM_log(''' ''message'', ''level'' ''')'''<br />
<br />
= Description =<br />
<br />
Allows script authors simple access to logging informational messages in the Error Console.<br />
This can be helpful for debugging.<br />
<br />
Level is optional and defaults to 0.<br />
Valid values are:<br />
<br />
; 0 : info<br />
; 1 : warning<br />
; 2 : error<br />
<br />
= Examples =<br />
<br />
GM_log("Hello, World!");<br />
<br />
= Notes =<br />
<br />
GM_log is available in [[Greasemonkey]] version 0.3 and later.<br />
<br />
<br />
[[Category:API Reference|L]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM.setValue&diff=1645GM.setValue2006-12-06T03:30:19Z<p>LouCypher: categorized</p>
<hr />
<div>__NOTOC__<br />
{{underscore|title=GM_setValue}}<br />
<br />
= Syntax =<br />
<br />
'''GM_setValue(''' ''name'', ''value'' ''')'''<br />
<br />
= Description =<br />
<br />
Allows user script authors to persist simple values locally.<br />
Strings, booleans, and integers are the only allowed data types.<br />
<br />
Values are stored in the [http://kb.mozillazine.org/Dev_:_Using_preferences Firefox preferences] back end.<br />
This places limitations on the size of an individual value, and the number of values.<br />
''(Please check correctness of this statement.)''<br />
<br />
= Examples =<br />
<br />
alert(GM_setValue("foo", "bar"));<br />
<br />
= See Also =<br />
<br />
* [[GM_getValue]]<br />
<br />
<br />
[[Category:API Reference|S]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM.getValue&diff=1644GM.getValue2006-12-06T03:29:50Z<p>LouCypher: </p>
<hr />
<div>__NOTOC__<br />
{{underscore|title=GM_getValue}}<br />
<br />
= Syntax =<br />
<br />
'''GM_getValue(''' ''name'', ''default'' ''')'''<br />
<br />
= Description =<br />
<br />
Retrieve a value set with [[GM_setValue]].<br />
If the value is not found, default is returned instead.<br />
If default is not supplied, <code>undefined</code> is returned.<br />
<br />
= Examples =<br />
<br />
alert(GM_getValue("foo"));<br />
<br />
= See Also =<br />
<br />
* [[GM_setValue]]<br />
<br />
<br />
[[Category:API Reference|G]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM.getValue&diff=1643GM.getValue2006-12-06T03:28:47Z<p>LouCypher: categorized</p>
<hr />
<div>__NOTOC__<br />
{{underscore|title=GM_getValue}}<br />
<br />
= Syntax =<br />
<br />
'''GM_getValue(''' ''name'', ''default'' ''')'''<br />
<br />
= Description =<br />
<br />
Retrieve a value set with [[GM_setValue]].<br />
If the value is not found, default is returned instead.<br />
If default is not supplied, <code>undefined</code> is returned.<br />
<br />
= Examples =<br />
<br />
alert(GM_getValue("foo"));<br />
<br />
= See Also =<br />
<br />
* [[GM_setValue]]<br />
<br />
<br />
[[Category:API Reference|S]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=GM_addStyle&diff=1642GM addStyle2006-12-06T03:25:53Z<p>LouCypher: categorized</p>
<hr />
<div>{{underscore|title=GM_addStyle}}<br />
<br />
= Syntax =<br />
<br />
'''GM_addStyle(''' ''css'' ''')'''<br />
<br />
= Description =<br />
<br />
Adds a string of CSS to the document.<br />
<br />
Creates a new <code><style></code> element, adds the given CSS to it, and inserts it into the <code><head></code>.<br />
<br />
= Examples =<br />
<br />
GM_addStyle("body { color:red; }");<br />
<br />
<br />
[[Category:API Reference|A]]</div>LouCypherhttps://wiki.greasespot.net/index.php?title=Category:API_Reference&diff=1641Category:API Reference2006-12-06T03:25:00Z<p>LouCypher: </p>
<hr />
<div><!-- --></div>LouCypherhttps://wiki.greasespot.net/index.php?title=API_reference&diff=1640API reference2006-12-06T03:22:15Z<p>LouCypher: categorized</p>
<hr />
<div>* [[GM_addStyle]]<br />
* [[GM_getValue]], [[GM_setValue]]<br />
* [[GM_log]]<br />
* [[GM_openInTab]]<br />
* [[GM_registerMenuCommand]]<br />
* [[GM_xmlhttpRequest]]<br />
* [[unsafeWindow]]<br />
<br />
Note:<br />
All GM_* functions, including, were blocked in version 0.3.5, due to security vulnerabilities.<br />
These functions were restored, with updates making them secure, in version 0.5.<br />
<br />
[[Category:API Reference|*]]</div>LouCypher