I modded a script I found to show dock badges for both the inbox and
notifications.  I had a previous script I did that started to act
funky once the new facebook was deployed.  Props to the guy who made
the original script I modded.



// ==UserScript==
// @name           Facebook | Inbox Notifications
// @namespace      http://www.ronaldtroyer.com/
// @description    Changes the title bar facebook to include
notification and inbox totals
// @version        1.0
// @include        http://*facebook.com*
// @include        https://*facebook.com*
// @exclude        http://*facebook.com
// @exclude        http://*facebook.com/
// @exclude        https://*facebook.com
// @exclude        https://*facebook.com/
// @exclude        http://*facebook.com/index*
// @exclude        https://*facebook.com/index*
// ==/UserScript==

if (!window.fluid) {
        return;
}

try {
        doBadgeUpdates(5000);
} catch(e) {

        window.console.log(e);
}

var currentTitle = document.title.substring(11);                        // Set 
current
Title

var thisNot = '';                                                               
                        // Setting variables for later
var thisInb = '';                                                               
                        // Setting variables for later
var thisTotal = '';                                                             
                        // Setting variables for later

var spans = document.getElementsByTagName('span');                      // Get 
all <span>
elements

window.getNumbers = function () {
        document.title = currentTitle + ' | Facebook';                          
        // Set title bar
first for ever so slightly snappier results

        for (i=0; i<spans.length; i++) {                                        
                        // Loop through all <span>
elements

                if (spans[i].id == 'presence_notifications_count') {            
// If this is
the notifications
                        thisNot = spans[i].innerHTML;                           
                        // Set variable to current
Notification HTML
                        thisNot = thisNot.replace(/\<[^\>]*\>/g, '');           
        // Remove HTML
tags
                        thisNot = thisNot.replace(/\[[^\]]*\]/g, '');           
        // Remove anything
within square brackets
                        thisNot = thisNot.replace(/\strong/, '');               
                // Replace the
strong

                        if (thisNot=='') {                                      
                                        // If there are no new notifications
                                thisNot = 0;                                    
                                        // Set to zero
                        } else {                                                
                                                // If there are new 
notifications
                                thisNot = parseInt(thisNot);                    
                        // Make it a number instead of a
string
                        }
                }

                if (spans[i].id == 'fb_menu_inbox_unread_count') {              
// If this is
the inbox section
                        thisInb = spans[i].innerHTML;                           
                // Set variable to current Inbox
HTML
                        thisInb = thisInb.replace(/\<[^\>]*\>/g, '');           
        // Remove HTML
tags
                        thisInb = thisInb.replace(/\[[^\]]*\]/g, '');           
        // Remove anything
within square brackets

                        if (thisInb=='') {                                      
                                        // If there are no new inbox items
                                thisInb = 0;                                    
                                        // Set to zero
                        } else {                                                
                                                // If there are new inbox items
                                thisInb = parseInt(thisInb);                    
                        // Make it a number instead of a
string
                        }
                }

        }//end loop

        thisTotal = thisNot + thisInb;                                          
        // Add up totals
        if (thisTotal==0) {                                                     
                        // If there are no new notifications or
inbox items
                thisTotal = '';                                                 
                        // Don't display any number
        } else {                                                                
                                // If there are new notifications or inbox items
                thisTotal = thisTotal;                                  // Set 
text to display in title bar
         window.fluid.dockBadge = thisTotal;

        }
        document.title = '(' + thisTotal + ') ' + document.title;               
        // Set
title bar

        window.setTimeout(getNumbers);                                  // Set 
recurrence
}

getNumbers();                                                                   
                        // Run function at startup
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"fluidapp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluidapp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to