Skip to main content
3 of 9
added 235 characters in body
Fosco
  • 191
  • 1
  • 7

A user script to update the page/tab title with # of unread notifications

##About

Per this question: http://meta.stackoverflow.com/questions/57315/can-we-get-notification-in-the-tab-change-of-title This user script was created to help draw attention to notifications even when the tab isn't in focus. It changes the page title to include the 'unreadCount' from the StackExchange SuperCollider.

Code

// ==UserScript==
// @name           SE Tab Notifier
// @namespace      http://fosco.com
// @description    Update Tab Title when Inbox has content
// @include        http://*.stackexchange.com/*
// @include        http://superuser.com/*
// @include        http://serverfault.com/*
// @include        http://meta.stackoverflow.com/*
// @include        http://stackoverflow.com/*
// ==/UserScript==


var script = document.createElement("script");
script.textContent = "(" + grease.toString() + ")()";
document.body.appendChild(script);

function grease()
{
 var notifyme = function ()
 {
       var x = $(document).attr('title');
       var hack = x.split(' ');
       if (parseInt(hack[0]) > 0) {
           hack = hack.slice(1);
           hack = hack.join(' ');
           $(document).attr('title',hack);
           x = hack;
       }
       if ($('#portalLink a.unreadCount').is(':visible')) {
               var count = $('#portalLink a.unreadCount').text();
               var len = Math.floor(count/10);
               if (x.substring(0,len+2) != count + ' ') {
                       $(document).attr('title',count + ' ' + x);
               }
       }
 };
 window.setInterval(notifyme, 1000);
}

###License

Free!

###Platform

Chrome/GreaseMonkey

##Contact

gfosco AT gmail

Fosco
  • 191
  • 1
  • 7