BJAX With Greasemonkey for Firefox and IE
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'
Topics: BJAX, Greasemonkey
Comments: 1 so far
Leave a comment
About Pathfinder
Follow the Blog
-
Get a monthly update on best practices for delivering successful software.
Subscribe via email
Subscribe via RSS
Categories
Topics
Archives
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
Blogroll
Recent
- Elements of Testing Style
- Aesthetics and Web Design
- Asterisk-Java Testing with Groovy
- 3 Misuses of Code Comments
- Fluently NHibernate
- Digging a Hole and Covering it with Leaves — The Software Development Version
- The Importance of User Experience - Do You Understand It in Your Bones?
- Writing Your Own Protocol With NSURLProtocol
- What’s In Your Dock: iPhone edition
- Feature Fatigue



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