envjs, eh?
this is about the most intriguing thing i've come across in a long time. a project to let you run jquery within rhino...
why would you want something like this? well, say you need to extract some information from a web site. a few years ago, for example, i was assigned at work to copy-and-paste data off of a web-based calendar into microsoft outlook. i copied and pasted my little hand off, and had barely made a dent in it. i had been playing with perl a little bit back then, and wrote up a program that loaded the web pages and pulled the data out for me. then a second program loaded that data into outlook. lots of companies and people these days would like to be able to extract data like this and use it in another format. using perl works, but is a little cumbersome.
rhino is basically a javascript interpreter, written in java. you can write javascript programs, and rhino also provides a bridge to java so your javascript programs can access the java api. it does not, however, provide a standard browser-like environment, so something like jquery won't run natively within it. there's no notion of window, document, and so forth like there is when javascript runs in a browser.
that's where envjs comes in. fire up rhino, load envjs, and the possibilities are almost endless:
$ java -jar dist/env-js.jar
Rhino 1.7 release 3 PRERELEASE 2009 07 08
js> load('dist/env.rhino.js')
js> window.location = 'http://john.cheslicious.com'
INFO: [Tue Oct 13 2009 22:51:29 GMT-0600 (MDT)] {ENVJS} adding value to history: http://john.cheslicious.com
INFO: [Tue Oct 13 2009 22:51:32 GMT-0600 (MDT)] {ENVJS} Sucessfully loaded document at http://john.cheslicious.com
http://john.cheslicious.com
js> load('jquery.js')
js> $('#navigation a').each(function() { print ($(this).text()) })
home
stuff n' things
projects
about
contact
[object Object]
js>
sweet, eh? that's just a simple example. you could use this to fill in and submit forms, extract whatever data or links you're interested in...and so on.
the only trouble is that envjs can have trouble parsing poorly-formed documents- which a lot of pages out in the wild are. luckily i can extract data from my own web site without a problem though :P