Fixed Nov. 30th 2008

in
Subscribe to Fixed Nov. 30th 2008 2 posts, 2 voices



Christian Li... User

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("");
}
}

 
Kahil Young Script's Author

I've tried using your revision and nothing shows up whatsoever... any ideas?

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel