Inject Dojo

Sad to say, most of the web doesnt yet use dojo. But that needn’t stop you. Inject Dojo

    var d=document; 
    var h=d.getElementsByTagName("HEAD")[0]; 
    var s=d.createElement("script"); 

Its a simple bookmarklet to inject AOL’s copy of dojo 1.2.* into the current page. Once there, you have dojo at your disposal in the console. The following can be run in your console (e.g. Firebug) live against this page on


You can load packages at will of course. If they are on the CDN, they are yours for the taking. And dojo.query beats out firebug’s $$ for DOM querying and manipulation

How about something useful:

dojo.query("textarea#comment").forEach(function(t) { t.value = dojo.toJson( dojo.version, true ) })

That’s still contrived, but it shows dumping a json-ified javascript object (prettily - by using the second boolean param to toJson) to a textarea on the page.

One more - the impetus for this post actually - cleaning up a page on the fly and capturing the innerHTML for use elsewhere:

dojo.query("#menu-customer, #teaser, .dojoc-article-info, #respond, #comment").orphan();
var t = dojo.doc.createElement("textarea"); 
t.value=dojo.body().innerHTML;, dojo.body())

For more inject-dojo fun, check out Shane O’Sullivan’s DaftMonkey - a dojo/greasemonkey integration