-
-
Save josh-h/1821265 to your computer and use it in GitHub Desktop.
Trello activity userscript for FluidApp
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 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