|
I modified a little bit to work with the current Facebook format. Minor changes. Also, hides badge when there are 0 notifications.
// ==UserScript==
// @name Facebook Dock Badges
// @namespace http://fluidapp.com
// @description Display a dock badge for Facebook when using Fluid.
// @include *.facebook.com/*
// @author Kahil Young
// ==/UserScript==
if (!window.fluid) {
return;
}
try {
doBadgeUpdates(60000); //check every 60 seconds
} catch(e) {
window.console.log(e);
}
function doBadgeUpdates(timeout) {
//just regex for a digit. easy.
updateBadge("presence_notifications_count", /(\d+)/);
setTimeout(doBadgeUpdates, timeout);
}
function updateBadge(id, new_post_regex) {
notice_divs = document.getElementById(id).getElementsByTagName('strong');
if ((notice_divs.length || 0) > 0) {
new_post_html = notice_divs[0].innerHTML;
count = new_post_regex.exec(new_post_html)[0];
window.fluid.setDockBadge(count);
} else {
window.fluid.setDockBadge("");
}
}
|