Skip to content

Instantly share code, notes, and snippets.

@aggieben
Forked from aschempp/harvest-growler.user.js
Created July 11, 2012 22:01
Show Gist options
  • Save aggieben/3093927 to your computer and use it in GitHub Desktop.
Save aggieben/3093927 to your computer and use it in GitHub Desktop.
Fluid userscript for Harvest CO-OP Timer app. Pops a Growl notification every so often to remind me to track my hours if no timer is currently running.
// ==UserScript==
// @name CO-OP Timer Growl Reminder
// @namespace http://coopapp.com
// @description Displays Growl notifications at a user defined interval, reminding you to track your time.
// @include *
// @author Andreas Schempp
// @author Mike Green
// @version 0.1.1
// ==/UserScript==
(function () {
if (window.fluid) {
var growlInterval = 45000; // (in milliseconds)
window.growlReminder = window.setInterval(growlAtUser, growlInterval);
coop.current_user_class = 'user_' + document.getElementById('controls').firstDescendant().href.match(/\d+/);
// TODO: Create a form to set the notification interval
// Create a link to start/stop the notifications
var pauseLink = document.createElement('a');
pauseLink.href = "#";
pauseLink.innerHTML = "Stop Growl Reminders";
pauseLink.onclick = function(e) {
if (window.growlReminder) {
window.clearInterval(window.growlReminder);
window.growlReminder = null;
e.target.innerHTML = "Start Growl Reminders";
} else {
window.growlReminder = window.setInterval(growlAtUser, growlInterval);
e.target.innerHTML = "Stop Growl Reminders";
}
return false;
};
document.getElementById('controls').insertBefore(pauseLink, document.getElementById('controls').firstChild);
}
})();
function timerStopped() {
try {
return ($$('div.entry.current_timer.' + coop.current_user_class).length == 0);
} catch(e) {
return true;
}
}
function growlAtUser() {
if (timerStopped()) {
window.fluid.showGrowlNotification({
title: "Track your time!"
, description: "Harvest wants to know what you're working on."
, priority: 1
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment