Menu

Greasemonkey_Manual:API

mmartz

Getting StartedInstalling ScriptsManaging ScriptsMonkey MenuCreating ScriptsEnvironmentOther Useful Tools ⬌ API

Description

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 the User script. 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.

| Notes

The API

| Values | Resources | Common Task Helpers | Other| Special

Headers

Metadata Block : Uses JavaScript comments to identify a user scripts information and capabilities.

Values

GM_deleteValue : Deletes a single name to value from persistent storage.
GM_getValue : Retrieves a single name to value from persistent storage.
GM_listValues : Retrieves an array of names to values that start with the root from persistent storage.
GM_setClipboard : Copies temporary storage data to the local clipboard.
GM_setValue : Sets a single name to value in persistent storage.

Resources

GM_getResourceText : Loads raw, plaintext from a resource.
GM_getResourceURL : Loads an external resource via a URL, such as an image, and returns the string containing the base64 encoded in the data: URL scheme.

Common Task Helpers

GM_addStyle : Appends a CSS style element to the head element of window.
GM_xmlhttpRequest : Provides a cross-origin xmlHttpRequest.
unsafeWindow : Provides access to the Content Scope (a.k.a the restricted namespace) window object.

Other

GM_log : Outputs a chrome message to the Error Console. This is useful for examining values when writing a script.
GM_openInTab : Opens a new Url in a new tab
GM_registerMenuCommand : Inserts a menu item into the Monkey Menu

Special

GM_info : Exposes some information to the user script via an Object

Getting StartedInstalling ScriptsManaging ScriptsMonkey MenuCreating ScriptsEnvironmentOther Useful Tools ⬌ API

Notes

All GM_* functions were blocked in version 0.3.5, due to security vulnerabilities. These functions were restored with updates making them secure, and the new unsafeWindow object was added, in version 0.5 beta


Related

Wiki: GM_addStyle
Wiki: GM_deleteValue
Wiki: GM_getResourceText
Wiki: GM_getResourceURL
Wiki: GM_getValue
Wiki: GM_info
Wiki: GM_listValues
Wiki: GM_log
Wiki: GM_openInTab
Wiki: GM_registerMenuCommand
Wiki: GM_setClipboard
Wiki: GM_setValue
Wiki: GM_xmlhttpRequest
Wiki: Greasemonkey_Manual:Creating_Scripts
Wiki: Greasemonkey_Manual:Environment
Wiki: Greasemonkey_Manual:Getting_Started
Wiki: Greasemonkey_Manual:Installing_Scripts
Wiki: Greasemonkey_Manual:Managing_Scripts
Wiki: Greasemonkey_Manual:Monkey_Menu
Wiki: Greasemonkey_Manual:Other_Useful_Tools
Wiki: Metadata_Block
Wiki: Script_injection_rules
Wiki: User_script
Wiki: unsafeWindow

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.