Monday, April 7, 2008

Yahoo! Web Messenger Meets Fluid.app

This evening I decided to play with a really kewl new app called Fluid. What this app does is allow you to create Site Specific Browsers. One of the first usages which popped into mind was a product I helped develop, Yahoo! Web Messenger. An annoyance of mine with it is that it had to live in a browser tab, something prone to getting closed accidentally, and also didn’t have any decent notifications of new messages when not in focus. Being the perfect candidate for Fluid, IMHO, I set out to give it a shot. In less than an hours time I built a pretty kewl demo and here’s how you can use it too.

Read on for a howto and example video!

  1. First things first, you need to download and install Fluid. You can do this by visiting http://fluidapp.com. After installing it, fire up the app.
  2. Second off, we now need to create our SSB instance. For the URL, enter in
    http://webmessenger.yahoo.com

    For the name use something like

    Yahoo! Web.IM

    or whatever else strikes your fancy. The icon you can download from here. Click create and you are all set.

  3. Next we can fire up the application. It should live inside your applications folder just like any other desktop app. You use Quicksilver right?
  4. Now that the app is running, you can see the normal login screen of Web.IM and if you like, sign in just as a test.
  5. Next comes the real powerful part. We need to create a new “userscript” which will add advanced functionality over what a normal browser experience provides. We do this by clicking on the Userscripts menu and then selecting “New Userscripts…”, or you can use Cmd-Option-N if you are a keyboard shortcut lover like me. Type in a meaningful name, I used WebIM, and then a new script editor opens. Paste the following code into the window replacing what was there already and then save and close the script editor.
    1. // ==UserScript==
    2. // @name WebIM
    3. // @namespace http://www.jeremyjohnstone.com
    4. // @description Enables advanced notifications and disables ads
    5. // @include *
    6. // @author Jeremy Johnstone
    7. // ==/UserScript==
    8. (function () {
    9. if (window.fluid) {
    10. // unread is a bit of misnomer, because we clear this
    11. // as soon as the window regains focus, not when you
    12. // actually read the IM (TODO: telepathy enabled?)
    13. var unreadIMCount = 0;
    14. // store the state of the user being active
    15. var activeState = true;
    16. // I don’t want ads in my IM client
    17. window.showAd = function(locale) { }
    18. // When the window regains focus, clear the unread IM count
    19. // Also save the state for other functions
    20. window.onfocus = function() {
    21. activeState = true;
    22. unreadIMCount = 0;
    23. window.fluid.dockBadge = “”;
    24. }
    25. window.onblur = function() {
    26. activeState = false;
    27. }
    28. // disabling this turns off the normal new IM
    29. // notification (aka the scrolling title message)
    30. window.startNotify = function(msg) { }
    31. // Here we latch into the advancedNotify which
    32. // splits out the yid from the msg separately
    33. window.advancedNotify = function(yid, msg) {
    34. // We don’t want to show growl alerts if the
    35. // user is active already
    36. if(activeState) return;
    37. msg = unescape(msg);
    38. window.fluid.showGrowlNotification({
    39. title: “New Message from: “ + yid,
    40. description: msg,
    41. priority: 1,
    42. sticky: false,
    43. identifier: null,
    44. onclick: null
    45. });
    46. // Now we increment the unread IM count and then
    47. // set the dockBadge to be the number of unseen IMs
    48. unreadIMCount++;
    49. window.fluid.dockBadge = unreadIMCount;
    50. }
    51. // Instead of blowing away the cookies going to login,
    52. // Let’s just close the app instead
    53. window.exit = function(url) {
    54. // seems neither of these work… hmmm..
    55. // fluid bug???
    56. window.fluid.terminate();
    57. window.fluid.hide();
    58. }
    59. }
    60. })();
  6. Finally, not sure this is needed, but I found it easiest to quit the app and restart it as that way you know for sure your script got loaded right. Probably not needed, but always safer. Also check the Userscripts menu and you should see a menu option for your new script. Make sure there is a check mark next to it. If so, go ahead and sign in as usual.

That’s it! You now have a new Web Messenger client inside it’s own browser tab with the following new features:

  • Growl Notifications for IMs received when the app isn’t in focus
  • Dock Badge updates with the count of unread IMs received
  • No advertising banners shown

My hope is that I can get the author of Fluid to add a couple more improvements which will make it even better as well as hopefully fix what I think is a bug with hide() and terminate() not working. With dock icon bouncing and a separate cookie jar for each application this will be immensely useful, IMHO.

Here’s a little video tutorial taking you through the steps above.


Enjoy!


courtesy : jeremyjohnstone.com

0 comments:

Blogger port by Blogger Templates

Powered by Blogger, state-of-the-art semantic personal publishing platform