Skip to content
supahgreg edited this page Mar 15, 2011 · 30 revisions

Scriptish offers a few API methods which provide extra functionality to user scripts.

Headers

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.


Constants

GM_updatingEnabled

Always equal to true. Check if this exists to see if your user script engine supports @updateURL.

unsafeWindow

Provides access to the raw window, which is usually used to access functions defined on a page.


Values

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.

This function will set a user script preference.


Resources

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.


User Interface

This function sends messages to the Error Console.

GM_notification (new in Scriptish!)

This function sends a Growl-style notification/message to the user.

This function opens a URL in a new tab, or optionally an existing tab.

This function will add a menu item to the Scriptish statusbar menu which runs a provided command when clicked.

GM_unregisterMenuCommand (new in Scriptish!)

This function will remove a GM_registerMenuCommand-created menu item from the Scriptish statusbar menu.

GM_setClipboard (new in Scriptish!)

This function will save data to the clipboard.


Other

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.