-
Notifications
You must be signed in to change notification settings - Fork 70
Manual: API
Scriptish offers a few API methods which provide extra functionality to user scripts.
Using a specially formatted block of JavaScript comments Scriptish is able to read metadata about a user script. This is used by a user script author to pass Scriptish information such as who wrote or contributed to the script, conditions under which the script should be used, licensing details, dependencies, etc.
GM_getMetadata (new in Scriptish!)
This function provides access to a user script's metadata block.
Always equal to true
. Check if this exists to see if your user script engine supports @updateURL.
Provides access to the raw window
, which is usually used to access functions defined on a page.
This function will remove a user script preference.
This function will retrieve a user script preference.
This function will return a list of a user script's preferences.
GM_setValue (improved in Scriptish!)
This function will set a user script preference.
Note: Resources are included with a Metadata Block's @resource key.
This function will return the plain text content of a @resource.
This function will return the contents of the @resource as a data: URL.
This function sends messages to the Error Console.
GM_notification (new in Scriptish!)
This function sends a Growl-style notification/message to the user.
GM_openInTab (improved in Scriptish!)
This function opens a URL in a new tab, or optionally an existing tab.
GM_registerMenuCommand (improved in Scriptish!)
This function will add a menu item to the Scriptish menu under "User Script Commands".
GM_unregisterMenuCommand (new in Scriptish!)
This function will remove a GM_registerMenuCommand-created menu item from the Scriptish menu.
GM_enableMenuCommand (new in Scriptish!)
This function will enable a GM_registerMenuCommand-created menu item in the Scriptish menu.
GM_disableMenuCommand (new in Scriptish!)
This function will disable a GM_registerMenuCommand-created menu item in the Scriptish menu.
GM_setClipboard (new in Scriptish!)
This function will save data to the clipboard.
This function takes a string of CSS and adds it to the page.
GM_cryptoHash (new in Scriptish!)
This function will allow you to easily hash a string.
GM_generateUUID (new in Scriptish!)
This function will return a UUID using nsIUUIDGenerator.
GM_safeHTMLParser (new in Scriptish!)
This function will safely parse a string of HTML and return a document object. It cleans the provided HTML by removing tags like <script>
, <style>
, <head>
, <body>
, <title>
, and <iframe>
, and it will also remove all JavaScript, including element attributes that contain JavaScript.
This function is a cross-origin version of XMLHttpRequest. The beauty of this function is that a user script can make requests that do not use the same-origin policy, creating opportunities for powerful mashups.