Netvibes dock displayer

By Aves Last update Jun 25, 2008 — Installed 259 times. Daily Installs: 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0
// ==UserScript==
// @name        Netvibes dock displayer
// @namespace   http://www.awaken-dreamer.org
// @description Netvibes dock badge displayer for Fluid
// @include     http://www.netvibes.com/*
// @author      Gauthier Roebroeck
// ==/UserScript==

// Put the 4 first letters of your page's title
var page_title = "Aves";

(function() {
    if (!window.fluid) {
        return;
    }
    
    if(document.title.substring(0,4) != page_title){
    	return;
    }
    
    var fluid_unread = 0;
    
    function updateDockBadge() {
        var title = document.title;
        var old_fluid_unread = fluid_unread || 0;

        if (title && title.length) {
            var start = title.indexOf("(");
            var end = title.indexOf(")");
            if (start > -1 && end > -1) {
                start++;
                fluid_unread = title.substring(start, end);
            } else {
                fluid_unread = 0;
            }
        }
        
        //set the dock badge
        if ((fluid_unread || 0) > 0) {
            window.fluid.setDockBadge(fluid_unread);
        } else {
            window.fluid.setDockBadge("");  
        }
    }
    setInterval(function(){updateDockBadge();}, 3000);
})();