Wave Growl

By tanguy Last update Oct 2, 2009 — Installed 1,643 times. Daily Installs: 4, 1, 10, 2, 10, 8, 4, 3, 8, 1, 5, 17, 3, 3, 6, 2, 14, 0, 10, 3, 4, 1, 2, 4, 0, 3, 5, 4, 4, 0, 0, 3
// ==UserScript==
// @name        Wave Growl
// @namespace   http://fluid.com
// @description Wave Growl Notification for Fluid
// @include     https://wave.google.com/*

// ==/UserScript==

(function () {
    
	if (!window.fluid) {
		return;
	}

	var unreadMsgCount = 0;

	function growlNewMessages() {

		var oldCount = unreadMsgCount;
	
	
		var title = document.title;
		
        if (title && title.length) {
            var start = title.indexOf("(");
            var end = title.indexOf(")");
            if (start > -1 && end > -1) {
                start++;
                unreadMsgCount = title.substring(start, end);
            } else {
                unreadMsgCount = 0;
            }
        }
	
		// If the unread message count is greater than it was the last
		// time we checked, we know that we've received one or more new
		// messages.
		//alert(unreadMsgCount + ':' + oldCount)
		if (unreadMsgCount > oldCount) {
			
			fluid.showGrowlNotification({
				title: "Wave",
				description: unreadMsgCount + " unread message(s)",
				priority: 0,
				sticky: false
			});
		}
		if(unreadMsgCount != oldCount)
		{
			window.fluid.dockBadge = (unreadMsgCount == 0) ? '' : unreadMsgCount;
		}
	}
	
	// Check for new messages every 10 seconds
	window.setInterval(function(){growlNewMessages();}, 10 * 1000);
	
})();