mcornick (owner)

Revisions

gist: 116188 Download_button fork
public
Description:
display unread inbox messages in a Zimbra Fluid app
Public Clone URL: git://gist.github.com/116188.git
Embed All Files: show embed
zimbra-dock.user.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// ==UserScript==
// @name Zimbra dock badge updater for Fluid
// @namespace http://objectsinmirrors.com
// @description Zimbra dock badge updater for Fluid
// @include https://mail-1.01.com/*
// @author Mark Cornick, based on work by Gauthier Roebroeck
// ==/UserScript==
 
// almost entirely cribbed from http://userscripts.org/scripts/show/29097
 
(function() {
  if (!window.fluid) {
    return;
  }
 
  if(document.title.substring(0,13) != 'Zimbra: Inbox'){
    return;
  }
 
  var fluid_unread = 0;
 
  function updateDockBadge() {
    var title = document.title;
 
    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;
      }
    }
 
    if ((fluid_unread || 0) > 0) {
      window.fluid.setDockBadge(fluid_unread);
    } else {
      window.fluid.setDockBadge("");
    }
  }
  setInterval(function(){updateDockBadge();}, 3000);
}
)();