Turnabout / Write User Scripts

About developing user scripts

You can write your own user scripts for Turnabout. Users who selected Advanced user mode will be able to install and use your script.

Basics

User scripts are essentially JavaScript with some header metadata and some exposed APIs. If you can already write JavaScript that works in Internet Explorer 6, you're already well on your way to writing user scripts.

You can look at the scripts on the Get user scripts page to see examples of what a user script looks like.

Metadata

Turnabout supports all of the Greasemonkey metadata fields, as well as one of its own:

  • @library (use in place of @name) to indicate that a script is a library. All scripts can access variables and methods defined in a library.

APIs

Turnabout currently supports the following Greasemonkey APIs:

  • GM_log
  • GM_getValue
  • GM_setValue
  • GM_registerMenuCommand
  • GM_xmlhttpRequest

Browser differences

There's a number of differences between the major browsers' JavaScript engines, but once you've learned the basics, you should be able to write user scripts that work in Internet Explorer, Firefox, and Opera. Peter-Paul Koch's Quirksmode is a great reference for cross-browser scripting.

CSS support also differs. You might find the following resources useful:

Mostly, you will just have to test, test, test!

Greasemonkey user script development tutorial

Mark Pilgrim has written an excellent tutorial to user scripts called Dive Into Greasemonkey. It is, of course, Greasemonkey- and Firefox-oriented, so some details are inapplicable to Turnabout and Internet Explorer.

Porting Greasemonkey scripts

It's possible to write scripts that work in both Turnabout and Greasemonkey for Firefox. (In fact, all of the scripts that come with Turnabout should work in Greasemonkey.) Currently, there are few differences in plugin APIs; the greater hurdle is browser script compatibility.

The most common gotchas and support differences we've found in porting Greasemonkey scripts to work in Internet Explorer are the following:

XPath support
Internet Explorer 6 only supports XPaths on well-formed documents, so that's not very helpful on the web. Dimitri Glazkov's JavaScript XPath is could work, but since it's interpreted code, it's much slower than Mozilla's native code implementation. Your best bet for now is to get DOM nodes using other means, like DOM methods.
data:URIs
We've implemented support for these in IE, but it will only support fairly small URIs as specified by RFC 2397. Search the page for LITLEN.
Minor scripting differences
The vast majority of incompatibilities come from minor differences in browsers' JavaScript APIs, e.g. how to get your hands on event properties. A few visits to Quirksmode should take care of those.

Contribute your script

If your script works in Internet Explorer with Turnabout, please contribute it! We intend to share the future userscript.org repository with Greasemonkey scripts, but for now, please email us a copy of your script or send us a link.

Also, if you think your script would be useful for lots of Turnabout users and wouldn't mind letting us include it in a future version, let us know. When you send your script, be sure to include license information.