Safari Beta 2 adds a new do JavaScript command that enables AppleScript to communicate with the browser via JavaScript! See Apple's Do JavaScript Command page (note that there's a second page with more examples, as well as links to more extensive documentation).
Not terribly hinty, but worth a look if you'd like to use AppleScript to work with JavaScript on Safari pages.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20030417203258651