Skip to content

Instantly share code, notes, and snippets.

@josh-h
Forked from michaellopez/trello-activitiy
Created February 13, 2012 22:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josh-h/1821265 to your computer and use it in GitHub Desktop.
Save josh-h/1821265 to your computer and use it in GitHub Desktop.
Trello activity userscript for FluidApp
// ==UserScript==
// @name Trello Activity
// @namespace http://fluidapp.com
// @description Displays a Growl notification for new activities every 5 seconds. Also updates the badge.
// @include *
// @author Michael Lopez (michael@weahead.se)
// ==/UserScript==
(function () {
if (window.fluid) {
$(document).ready(function(){
window.fluid.dockBadge = '';
var prev;
var count = 0;
var growlMark = $('.list-actions .phenom').eq(0);
var processItem = function (item) {
var name = item.find('.member-initials').attr('title').replace(/ ?\([^\)]+\)$/, '');
var text = (name + ':\n' + item.find('.phenom-desc').eq(0).text()).replace(/(\s\s+|\n\n)/g, '\n');
growlMark = item;
if (prev != text) {
count += 1;
window.fluid.dockBadge = count;
prev = text;
window.fluid.showGrowlNotification({
title: 'New Trello Activity',
description: text,
priority: 1,
sticky: false,
identifier: 'trello' + Date.now() + Math.random(),
onclick: function() {
window.fluid.activate();
window.fluid.dockBadge = '';
count = 0;
},
icon: 'http://trello.com/images/favicon.png'
});
}
};
setInterval(function() {
if (growlMark) {
growlMark.parent().prevAll().each(function (i, e) {
$(e).children('.phenom').each(function (j, l) {
processItem($(l));
});
});
}
}, 5000);
$('*').click(function() {
count = 0;
window.fluid.dockBadge = '';
});
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment