Im At Work for Greasemonkey

February 3 2009, 11:38pm

I've put together a greasemonkey extension as mentioned in my video that tries to prevent you from visiting websites during working hours.

The free times are:

1) 08:00am to 09:00am (get to work early if you want to search) 2) 01:00pm to 02:00pm (lunch break you can search) 3) 04.00pm to 04.10pm (everyone can have a 10 minute break)

Download Im at Work.

Alternatively here is the source code:

// I'm At Work // Released to the public domain. // // ==UserScript== // @name I'm At Work // @description Turns time-wasting web pages invisible except between specific time windows (edit to initiatlize the multiple timeslots) // @include http://flickr.com/* // @include http://.flickr.com/ // @include http://metafilter.com/* // @include http://.metafilter.com/ // ==/UserScript== // // ==RevisionHistory== // Version 0.1: // Released: 2008-01-03. // Initial release. // // Version 0.2: // Released: 2008-11-16. // Modified initial release to have multiple Start and End timeslot windows for browsing // ==/RevisionHistory==

(function () { // EDIT THESE THREE SURF TIMESLOT WINDOWS FOR THE BLOCKED SITES TO APPEAR // HOURS IN MILITARY TIME, SO 15 = 3PM // ADD MINUTES IN DECIMAL FORM: 13.30 = 1:30 PM // STARTS WITH THREE SLOTS, AND CODE FOR THE FOURTH IS PROVIDED TO ADD MORE var surf_time1_start = 8.00; var surf_time1_end = 9.00; var surf_time2_start = 13.00; var surf_time2_end = 14.00; var surf_time3_start = 16.00; var surf_time3_end = 16.10; //var surf_time4_start = 18.00; //var surf_time4_end = 18.10; // END EDIT

var timeframe1 = false;
var timeframe2 = false;
var timeframe3 = false;
// var timeframe4 = false;
var timeframe  = false;

// Test to see if the current_time is within in any of the alloted Surfing times
var tstamp = new Date();
var current_time = tstamp.getHours()+(tstamp.getMinutes()/100);

// Check first surfing window
if ((current_time < surf_time1_end) && (current_time > surf_time1_start))
{
  timeframe1 = true;
}

// Check second surfing window
if ((current_time < surf_time2_end) && (current_time > surf_time2_start))
{
  timeframe2 = true;
}

// Check third surfing window
if ((current_time < surf_time3_end) && (current_time > surf_time3_start))
{
  timeframe3 = true;
}

// Check fourth surfing window
//if ((current_time < surf_time4_end) && (current_time > surf_time4_start))
//{
//  timeframe4 = true;
//}

// If any of the surfing windows are true, then allow the blocked sites to be seen
// if (timeframe1 || timeframe2 || timeframe3 || timeframe4)
if (timeframe1 || timeframe2 || timeframe3)
{
  timeframe = true;
}

// alert(timeframe1+" "+timeframe2+" "+timeframe3+" "+timeframe); // DEGBUG CONDITIONALS

 0.1
if (!timeframe)
{
    var b = (document.getElementsByTagName("body")[0]);
    b.setAttribute('style', 'display:none!important');
    alert("Surf between "+ surf_time1_start +" & "+surf_time1_end+
    " or\n  Surf between "+ surf_time2_start +" & "+surf_time2_end+
    " or\n  Surf between "+ surf_time3_start +" & "+surf_time3_end+
    // " or\n  Surf between "+ surf_time4_start +" & "+surf_time4_end+
    "\nBut right now, get back to work!");
}

})();