-
Get a monthly update on best practices for delivering successful software.
A few weeks ago I put together a BJAX example using Greasemonkey (BJAX = Browser Extensions and AJAX). The idea behind BJAX, of course, is that you can use AJAX widgets on third party sites and do cross domain scripting with ease. Two examples of BJAX apps are Book Burro,
which will get you book prices from competing retailers, and MyStickies,
Which will let you put stickies on pretty much any web site and use them on any computer where you have the MyStickies plugin installed. These BJAX applications go quite a bit beyond the original intent of Greasemonkey. They don't just enhance a few link but rather let you insert little mini-applications into someone else's webapp. This is potentially very disruptive to site owners, as they can no longer control their message. Amazon and Barnes and Noble can't be happy that people can seamlessly comparison shop, and the upcoming shareable feature of MyStickies could reduce the ability of community sites to moderate their own content.
My own BJAX application was built just for demo purposes in response to all the people who asked for a concrete example and thus wasn't particularly useful. It put the current weather in downtown Chicago, updated every minute, in a translucent box and floated it over the google.com search page. I decided to update it so it worked both with Firefox and IE and could run in the Greasemonkey clone for IE, Turnabout (get the advanced version, otherwise you won't be able to load your own scripts). The new, updated script can be found here. Three things have changed. Two of the changes are merely dealing with cross browser xml parsing and event handling. The third change is that clicking on the box now will toggle it from maximized to minimized.
Next steps are to port a client side AJAX framework so it uses GM_xmlhttpRequest, can handle being loaded after the page loads in Greasemonkey's sandbox, and doesn't have namespace conflicts with other AJAX frameworks. The mind races. Could GWT be adapted to build BJAX applications?
One potential issue with Greasemonkey and BJAX is that Greasemonkey runs after the page has loaded and all of the page's Javascript has run. What will happen with a true AJAX application that controls its DOM much more closely. Could our inserted DIV get deleted or munged? Should Greasemonkey fire after every DOM update or XMLHttpRequest?
Update 1: Johan Sundström takes me to task for being lazy. I've changed the test for GM_xmlhttpRequest to
typeof GM_xmlhttpRequest != 'function'
Related posts:
Topics: BJAX, Greasemonkey
Integration of GWT into Greasemonkey is a good idea, but…
It is not very easy:
http://dunck.us/collab/GreaseMonkeyUserScripts
Comment by Anton Ananich, Thursday, September 21, 2006 @ 9:36 am