Skip to content

Instantly share code, notes, and snippets.

@vasilisvg
Created July 14, 2011 08:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasilisvg/1082124 to your computer and use it in GitHub Desktop.
Save vasilisvg/1082124 to your computer and use it in GitHub Desktop.
Google+ unread messages userscript
// This script shows a badge with the number of new messages in the dock of your Fluid instance of Google+
// The count is reset when you click somewhere in the body
// This version of the script is written by Mathias Bynens
(function(window, document) {
var nodeList = document.getElementsByClassName('a-b-f-i a-f-i'), // live NodeList
fluid = window.fluid,
length;
document.onclick = function() {
length = nodeList.length;
fluid.dockBadge = '';
};
document.onclick();
setInterval(function() {
var currentLength = nodeList.length;
if (currentLength != length) {
fluid.dockBadge = currentLength - length;
}
}, 13e3);
}(this, document));
@vasilisvg
Copy link
Author

This script can definitely be improved. Your help would be very much appreciated.

@mathiasbynens
Copy link

// This script shows a badge with the number of new messages in the dock of your Fluid instance of Google+.
// The count is reset when you click somewhere in the document.

(function(window, document) {

    var nodeList = document.getElementsByClassName('a-b-f-i a-f-i'), // live NodeList
        fluid = window.fluid,
        length;

    document.onclick = function() {
        length = nodeList.length;
        fluid.dockBadge = '';
    };

    document.onclick();

    setInterval(function() {
        var currentLength = nodeList.length;
        if (currentLength != length) { 
            fluid.dockBadge = currentLength - length;
        }
    }, 13e3);

}(this, document));

Untested.

@vasilisvg
Copy link
Author

Wow, thanks!
Replaced my original script with mathiasbynens one.

@CodeIter
Copy link

not detected by greasemonkey because of missing userscript jsdoc.
try adding:

// ==UserScript==
// @name            Google Plus Message notification
// @description      Google Plus Message notification
// @namespace       plus.google.com
// @version         1.0.5
// @author           vasilisvg 
// @license         MIT
// @released        2011-07-14
// @updated         2011-07-14
// @match           *:// plus.google.com/*
// @run-at          document-start
// ==/UserScript==

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment