Greasemonkey Manual:API: Difference between revisions
From GreaseSpot Wiki
Jump to navigationJump to search
No edit summary |
GM.registerMenuCommand |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
=== Headers === | === Headers === | ||
; [[Metadata Block|Metadata Block]] : | ; [[Metadata Block|Metadata Block]] : Information about the script such as its name or version is encoded into comments by the script author. | ||
; [[ | ; [[GM.info]] : Exposes this information (plus a bit more) to the user script. | ||
=== Values === | === Values === | ||
; [[ | ; [[GM.deleteValue]] : Deletes a value from chrome that was previously set. | ||
; [[ | ; [[GM.getValue]] : Retrieves stored values, see [[GM.setValue]] below. | ||
; [[ | ; [[GM.listValues]] : Retrieves an array of stored values' keys. | ||
; [[ | ; [[GM.setValue]] : Permanently stores a value under a key, later available via [[GM.getValue]]. | ||
=== Resources === | === Resources === | ||
; [[ | ; [[GM.getResourceUrl]] : Provides a URL for loading a <code>@resource</code>, such as an image, into the page. | ||
=== Other === | === Other === | ||
; [[ | ; [[GM.notification]] : Opens a notification dialog. | ||
; [[ | ; [[GM.openInTab]] : Opens a given URL in a new tab. | ||
; [[GM.registerMenuCommand]] : Adds an item to the "User Script Commands" section of the [[Monkey Menu]]. | |||
; [[ | ; [[GM.setClipboard]] : Sets the contents of the clipboard. | ||
; [[ | ; [[GM.xmlHttpRequest]] : A variant of XMLHttpRequest, this method allows skipping use the same-origin policy, enabling complex mashups. | ||
; [[ | ; [[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. | ||
; [[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. | |||
[[Category:API Reference|*{{FULLPAGENAME}}]] | [[Category:API Reference|*{{FULLPAGENAME}}]] |
Latest revision as of 01:12, 28 January 2021
Greasemonkey Manual |
Using Greasemonkey |
---|
Installing Scripts |
Monkey Menu |
Getting Help |
User Script Authoring |
Editing |
Environment |
API |
This section of the manual will be short and sweet. As mentioned elsewhere, Greasemonkey provides several methods in its API to enhance the power of user scripts. 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!
Headers
- Metadata Block
- Information about the script such as its name or version is encoded into comments by the script author.
- GM.info
- Exposes this information (plus a bit more) to the user script.
Values
- GM.deleteValue
- Deletes a value from chrome that was previously set.
- GM.getValue
- Retrieves stored values, see GM.setValue below.
- GM.listValues
- Retrieves an array of stored values' keys.
- GM.setValue
- Permanently stores a value under a key, later available via GM.getValue.
Resources
- GM.getResourceUrl
- Provides a URL for loading a
@resource
, such as an image, into the page.
Other
- GM.notification
- Opens a notification dialog.
- GM.openInTab
- Opens a given URL in a new tab.
- GM.registerMenuCommand
- Adds an item to the "User Script Commands" section of the Monkey Menu.
- GM.setClipboard
- Sets the contents of the clipboard.
- GM.xmlHttpRequest
- A variant of XMLHttpRequest, this method allows skipping use the same-origin policy, enabling complex mashups.
- unsafeWindow
- This object provides access to the raw JavaScript
window
scope of the content page. It is most commonly used to access JavaScript variables on the page.