Fluid Gmail Userscript

This userscript seems to fix the infamous (and highly annoying) empty popup window bug in Fluid Gmail SSBs when clicking on a link out side of google.com.

Can anyone please take a look, make improvements, and post your version to www.pastie.org? Thanks! Bonus points if you can add Dock badge unread count support, dock menu support, or anything interesting with Growl Notifications (like Jesse did for the Google Reader script). Any improvements you make will likely be included in the release. I’ll certainly add your name to the credits in the About box, and praise your 1337 skillz here and on fluidapp.com (whatever that’s worth! :0p).

Note that I’m planning on shipping the next version Fluid with a small collection of Userscripts to totally replace all site-specific functionality currently in Fluid proper. That would include Gmail, Google Reader, Facebook, Yahoo! Mail and Flickr. If anyone wants to tackle these to help get this release out sooner, I’d be thrilled.

Sooo… feedback on the script below?

// ==UserScript==
// @name        Gmail
// @namespace   http://fluidapp.com
// @description Gmail features for Fluid
// @include     http://mail.google.com/*
// @author      Todd Ditchendorf
// ==/UserScript==

(function () {
    var closeId = null;
    var popUpWindow = null;
    var oldOpen = window.open;    

    window.open = function() {
        var url = arguments[0];
        if (!url) {
            clearTimeout(closeId);
            closeId = setTimeout(closeWindow, 100);
        }
        var res = oldOpen.apply(window, arguments);
        if (res) {
            popUpWindow = res;
        }
        return res;
    };

    function closeWindow() {
        popUpWindow.close();
    }
})();

7 Responses to “Fluid Gmail Userscript”

  1. Todd Says:

    Oh… and BTW, I have an unhealthy hatred of underscores… so you’re welcome to use them in your scripts, but any scripts that ship with fluid will be stripped of underscores and replaced with glorious, beautiful camel case variables. sorry!! :0]

  2. Pedro Melo Says:

    Hi,

    I know that Fluid it self is not open source, but have you consider hosting or encouraging some sort of open source effort for user scripts?

    Like TextMate and the bundle repository.

    Best regards,

  3. Jesse Newland Says:

    While I’m slammed today and can’t put much work into it, I’d love to port this to the Google Reader userscript as well so that the ‘v’ keyboard shortcut doesn’t open an extra popup.

    Thoughts on github.com as a repository for the userscripts? It’s free for open source efforts.

  4. The Doctor What Says:

    I have a slightly updated version at http://docwhat.gerf.org/files/tmp/gmailfix.user.js

    Basically: I fixed a problem where window.open() kept being overridden ad infinitum and added the https://... url to be included.

    Ciao!

  5. Luhmann Says:

    It would be much easier if this script were submitted to Userscripts.org, as that would allow easy installation via Fluid. It would also make it easy to find all fluid scripts in one place if everyone did this.

    Thanks!

  6. ed Says:

    Hi, just been trying this with 0.8.9 and it seems ‘reload userscripts’ doesn’t work. I had to quit and re-open the SSB to both enable the userscript and to have any changes to the script file reloaded.

  7. Bannus Says:

    This works for growl notifications in gmail:

    http://pastie.caboo.se/187265

    On a side note, does anyone know if it’s possible to create menu bar icons for gmail and google reader fluid apps?

Leave a Reply