Skip to content

Instantly share code, notes, and snippets.

@kmwallio
Last active May 9, 2017 16:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kmwallio/5638442 to your computer and use it in GitHub Desktop.
Save kmwallio/5638442 to your computer and use it in GitHub Desktop.
Userscript for badge icon and beep notifications for outlook.com in a Fluid App (SSB).
// use for patterns:
// *live.com*
// *outlook.com*
var playBeep = true;
window.fluid.dockBadge = '';
var numMessages = 0;
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
updateDockBadge();
// console.log("Loaded Userscript for Outlook Badge Notifications");
function updateDockBadge() {
var newBadge = '';
var inboxLink = document.querySelector('a[title^="Inbox"]');
var regex = /\s*\d+\s*/;
var text = '' + inboxLink.title;
if (text.length) {
// console.log('text: ' + text);
var res = text.match(regex);
// console.log('res: ' + res);
if (res && res.length > 0) {
newBadge = res[0].trim();
if (parseInt(newBadge) - numMessages > 0 && playBeep) {
window.fluid.playSound("Glass");
}
numMessages = parseInt(newBadge);
// console.log('newBadge: ' + newBadge);
}else{
numMessages = 0;
}
}
window.fluid.dockBadge = newBadge;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment