Created
November 16, 2010 16:52
-
-
Save parente/702062 to your computer and use it in GitHub Desktop.
my hacky inotes userscript
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
// ==UserScript== | |
// @name inotes | |
// @namespace http://aether.raleigh.ibm.com/ | |
// @description Adds Dock badge and Growl notification to iNotes in a Fluid SSB browser | |
// @include * | |
// @author Peter Parente <pparent@us.ibm.com> | |
// ==/UserScript== | |
(function () { | |
var authCol = 'e-listview-container-mail-Col2'; | |
var titleCol = 'e-listview-container-mail-Col3'; | |
var mailCont = 'e-listview-container-mail'; | |
var alarmCont = 'e-dialog-alarmAlert'; | |
var count = 0; | |
var alarm = false; | |
function checkMailContainer() { | |
var mail = window.frames[0].document.getElementById(mailCont); | |
// try again later, leave count alone | |
if(!mail) { return; } | |
var unread = mail.getElementsByClassName('vl-font-b'); | |
var l = unread.length; | |
// show unread count | |
if(l) { | |
window.fluid.dockBadge = ''+unread.length; | |
} else { | |
window.fluid.dockBadge = ''; | |
} | |
// play unread sound | |
if(l > count) { | |
window.fluid.playSoundNamed('Hero'); | |
// growl notices | |
for(var i=0; i < l; i++) { | |
var msg = unread[i]; | |
var author = msg.getElementsByClassName(authCol)[0]; | |
var title = msg.getElementsByClassName(titleCol)[0]; | |
var id = msg.getAttribute('unid'); | |
window.fluid.showGrowlNotification({ | |
title: author.textContent, | |
description: title.textContent, | |
priority: 1, | |
sticky: false, | |
identifier: id | |
}); | |
} | |
} | |
// store new count | |
count = l; | |
} | |
function checkCalendarAlert() { | |
var alert = window.frames[0].document.getElementById(alarmCont); | |
if(!alert || alert.className.search('s-nodisplay') > -1) { | |
// alert not visible | |
alarm = false; | |
return; | |
} | |
if(!alarm) { | |
// alarm now visible, notify | |
alarm = true; | |
var date = 'e-dialog-alarmAlert-on'; | |
var time = 'e-dialog-alarmAlert-at'; | |
var desc = 'e-dialog-alarmAlert-desc'; | |
window.fluid.playSoundNamed('Hero'); | |
window.fluid.showGrowlNotification({ | |
title: date.textContent + ' ' + time.textContent, | |
description: desc.textContent, | |
priority: 1, | |
sticky: true | |
}); | |
} | |
} | |
function update() { | |
checkMailContainer(); | |
checkCalendarAlert(); | |
} | |
if (window.fluid && document.body) { | |
var origOnLoad = document.body.onload; | |
document.body.onload = function() { | |
console.log('inotes user script loaded'); | |
origOnLoad(); | |
setInterval(update, 5000); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment