@grant: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
Created page with "<div style="border: 3px dotted; color: red; font-size: 1.2em; padding: 0.5em; margin: 1em; text-align: center"> This page describes features that are currently unreleased. </d..."
 
No edit summary
Line 9: Line 9:
* If a script does not specify any <code>@grant</code> values, Greasemonkey will attempt to auto-detect the right settings.
* If a script does not specify any <code>@grant</code> values, Greasemonkey will attempt to auto-detect the right settings.
* If a script specifies any values (or they have been auto detected), then it will be provided with ''only those'' [[API Reference|API]] methods that it declares.
* If a script specifies any values (or they have been auto detected), then it will be provided with ''only those'' [[API Reference|API]] methods that it declares.
** The valid values are those <code>GM_</code> prefixed values that you wish your script to be granted access to.  Until the documentation is finished, take a look at [https://github.com/greasemonkey/greasemonkey/blob/5402c32ef624041fb19d5b485fb012e8268e6ae7/modules/util/sniffGrants.js#L5 sniffGrants.js] which detects unspecified values.
* Otherwise the script will be granted no special API privileges, and thus run without the security constraints Greasemonkey scripts have traditionally had.  If you want your script to operate in this mode, you should explicitly declare <code>@grant none</code>.
* Otherwise the script will be granted no special API privileges, and thus run without the security constraints Greasemonkey scripts have traditionally had.  If you want your script to operate in this mode, you should explicitly declare <code>@grant none</code>.

Revision as of 22:01, 24 June 2012

This page describes features that are currently unreleased.

Greasemonkey 1.0 adds a special Metadata Block imperative: @grant. As of version 1.0:

  • If a script does not specify any @grant values, Greasemonkey will attempt to auto-detect the right settings.
  • If a script specifies any values (or they have been auto detected), then it will be provided with only those API methods that it declares.
    • The valid values are those GM_ prefixed values that you wish your script to be granted access to. Until the documentation is finished, take a look at sniffGrants.js which detects unspecified values.
  • Otherwise the script will be granted no special API privileges, and thus run without the security constraints Greasemonkey scripts have traditionally had. If you want your script to operate in this mode, you should explicitly declare @grant none.