Last active
May 9, 2017 16:06
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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