Created
November 17, 2010 19:29
-
-
Save mikedamage/703898 to your computer and use it in GitHub Desktop.
Fluid userscript for Harvest Timer app. Pops a Growl notification every so often to remind me to track my hours if no timer is currently running.
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 Harvest Timer Growl Reminder | |
// @namespace http://harvestapp.com | |
// @description Displays Growl notifications at a user defined interval, reminding you to track your time. | |
// @include * | |
// @author Mike Green | |
// @version 0.1.1 | |
// ==/UserScript== | |
(function () { | |
if (window.fluid) { | |
var growlInterval = 45000; // (in milliseconds) | |
window.growlReminder = window.setInterval(growlAtUser, growlInterval); | |
// 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('mainbody').appendChild(pauseLink); | |
} | |
})(); | |
function timerStopped() { | |
try { | |
return (window.timesheet.daily_stopwatch_timer_running_id == ""); | |
} 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 | |
}); | |
} | |
} | |
// vim: set ts=2 sw=2 smartindent : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Igdeon - Did you ever figure out a way to put an icon in the menubar? I'm looking for the same thing...