Skip to content

Instantly share code, notes, and snippets.

@kvangork
Created January 28, 2011 05:23
Show Gist options
  • Save kvangork/799872 to your computer and use it in GitHub Desktop.
Save kvangork/799872 to your computer and use it in GitHub Desktop.
Userscript for Growl notifications - Jaconda Fluid app - modify myRegexpNotify and windowTitle vars
var mostRecentMessageID = 0;
var myRegexpNotify;
function onAppInFG(){
window.fluid.dockBadge = "";
}
function callbackNewMessage(m){
if( !m.sender_name.match( myRegexpNotify ) ){
window.fluid.dockBadge = ( window.fluid.dockBadge * 1 ) + 1;
var growlID = "foo" + Math.random();
window.fluid.showGrowlNotification({
title: m.sender_name,
description: m.text.replace(/<br( )*(\/)*>/ig, "\n").stripTags().unescapeHTML(),
priority: ( m.text.match( myRegexpNotify ) != null ) ? 1 : 0,
sticky: false,
identifier: growlID,
onclick: function(){},
icon: '' // or URL string
});
}
}
(function () {
if (window.fluid) {
var load_the_stuff = function() {
setTimeout( function(){
var username = $$("#roomUsers > div.me a")[0].innerHTML.split(" ")[0];
myRegexpNotify = new RegExp(username, "i");
Jaconda.Socket.prototype._processNewMessage = Jaconda.Socket.prototype.processNewMessage;
Jaconda.Socket.prototype.processNewMessage = function (a) {
if (a.room_jid == this.chat.active_room && !this.chat.layout_manager.has_focus) {
callbackNewMessage( a );
}
return Jaconda.Socket.prototype._processNewMessage.call(this, a);
};
//prevent window title changes
var windowTitle = $$("head title")[0].innerHTML;
Jaconda.LayoutManager.prototype.updateTitle = function(){
document.title = windowTitle;
}
//disable new message sound
Jaconda.SoundManager.prototype.playSound = function(){};
console.log( 'Jaconda Fluid UserScript Ready to go.' );
}, 4000 );
Event.observe(window, 'focus', function() { onAppInFG(); });
window.fluid.dockBadge = "";
//uncomment next line to remove tabs
//$$( '.roomsTab' ).setStyle( {'display': 'none'} );
};
if (document.loaded) {
load_the_stuff();
}
else {
document.observe("dom:loaded", load_the_stuff);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment