Oomphify Bookmarklet?

Oct 23, 2008 at 2:22 AM
First of all Oomph, in concept, looks like a great idea and I'm looking forward to trying it out in real world cases, not just embedded on my own sites either.  So it seems to me that it would be trivial to create a bookmarklet that simply injects jQuery and oomph.min.js into the top of a page similar to the jQueryify bookmarklet.  Maybe it's due the late hour and long day I've had but for some reason I can't get a proof of concept working.  I'm waiting for jQuery.ready before injecting.  oomph_checkJQuery() should fire automatically but I'm obviously not doing something right.

Anway, if someone can figure this simply bookmarklet out I'm sure it would benefit many of us :)

Troy
Coordinator
Oct 23, 2008 at 5:58 PM

Wow, I hadn't even thought of that.  Are you thinking of a bookmarklet so that people can still use it without installing the toolbar?  The toolbar, of course, does this for your automatically.  If you check out toolbar.cpp in the source code, you can see exactly how we are doing it.

If you wanted to do it without the toolbar, the following JavaScript would work:

   var head= document.getElementsByTagName('head')[0];

   var script1 = document.createElement('script');
   script1.type= 'text/javascript';
   script1.src='https://visitmix.com/labs/oomph/1.0/client/jquery-1.2.6.min.js';
   head.appendChild(script1);

   var script2 = document.createElement('script');
   script2.type= 'text/javascript';
   script2.src='https://visitmix.com/labs/oomph/1.0/client/oomph.min.js';
   head.appendChild(script2);

This should definitelty work.  Let me know if you have any questions.  Note that there is no need to write your own code to wait for the jQuery to load -- Karsten already takes care of all of that (and eliminating name collisions) in oomph.js.

The only drawback to the bookmarklet approach, of course, is that you need to actually click the bookmarklet shortcut to detect the uf in a page, while the toolbar will automatically show you a "gleam" when there are uf in the page.

Oct 30, 2008 at 12:54 PM
Here is an example of the exact code needed for the Bookmark:

  javascript:(function(){function%20loadScript(scriptURL)%20{%20var%20scriptElem%20=%20document.createElement('SCRIPT');%20scriptElem.setAttribute('language',%20'JavaScript');%20scriptElem.setAttribute('src',%20scriptURL);%20document.body.appendChild(scriptElem);}loadScript('https://visitmix.com/labs/oomph/1.0/client/jquery-1.2.6.min.js');loadScript('https://visitmix.com/labs/oomph/1.0/client/oomph.min.js');})()

This is actually based on that for XRAY which has a similar approach for exposing the DOM - http://www.westciv.com/xray/
Coordinator
Oct 30, 2008 at 1:41 PM
Thanks metafeather,

I tweaked it to put the script tag in the head, and it's working fine as a bookmarklet in Google Chrome now.  It appears to inject the tags properly on Firefox as well, but the gleam isn't showing up -- I believe it's because of a difference in the way Firefox handles document complete, and I should be able to figure it out.  I'll test in Safari as well before uploading the final version, but if anyone is really eager to use it as a bookmarklet in chrome, your code will work.

Thanks!