Picture this: you sit down at your computer to write a report that’s due the
next day. You fire up a web browser to check the company intranet for a document.
For a split second you glance at your home page. “Wow!” you say. “The
Red Sox won in the 17th inning! Let me see what happened...”
Three hours later, no report’s been written, and you want to throw yourself
out the window.
Sound familiar?
It’s too easy to scamper down the rabbit hole of the Web when you’ve got
pressing tasks to work on. At one point or another, you’ve probably burned a
few hours clicking around Wikipedia, Amazon.com, eBay, Flickr, or Google
News and afterward hated yourself for it. This hack uses JavaScript to
blank out certain web sites during times you’re supposed to be working.
First, identify the biggest offenders — the sites you can spend hours clicking
around for no particular reason except boredom, procrastination, or lack of
more creative ways to spend your time..
To help yourself limit unproductive surfing, use this Invisibility Cloak user
script that turns time-wasting web sites blank before 3 p.m. (or whatever time
you configure). Here’s how to enable the Invisibility Cloak.
Install the Invisibility Cloak
The Invisibility Cloak JavaScript requires the Firefox web browser with the
Greasemonkey extension to run. Here’s how to get it set up.
1. Download and install the Greasemonkey Firefox extension from http://
greasemonkey.mozdev.org. (For detailed instructions on how to
install a Firefox extension, see Hack 71, “Extend Your Web Browser.”)
2. Using Firefox with Greasemonkey installed, go to the Invisibility Cloak
user script page at http://lifehackerbook.com/ch2/cloak
.user.js.
3. Click the Install button at the top right of the page
Set Which Sites Should Wear the Cloak
The Invisibility Cloak script is auto-configured to work on Metafilter
(http://metafilter.com) and Flickr (http://flickr.com), but you
want to it to work on the sites you choose.
1. In Firefox, select Tools → Manage User Scripts to edit, add, and remove
sites that should wear the cloak for you..
2. Use a wild card operator — the asterisk (*)— to indicate all pages on a
site. For example, http://flickr.com/* will apply the Invisibility
Cloak to all the pages on the Flickr.com domain.
3. When the Invisibility Cloak is enabled (the Enabled check box is
selected), visit one of the specified web sites before 3 p.m. and you get
the message.
Customize the Script
You can customize the Invisibility Cloak script further by hand-editing the
code. Following is the JavaScript body of the script. You’ll edit the bold lines in
a minute.
// Invisibility Cloak
// version 0.2
// Gina Trapani
// 2006-01-03
// Released to the public domain.
//
// ==UserScript==
// @name Invisibility Cloak
// @description Turns time-wasting web pages invisible until ;
a specified time of day; optionally on weekdays only.
// @include http://flickr.com/*
// @include http://*.flickr.com/*
// @include http://metafilter.com/*
// @include http://*.metafilter.com/*
// ==/UserScript==
//
// ==RevisionHistory==
// Version 0.1:
// Released: 2006-01-03.
// Initial release.
//
// Version 0.2:
// Released: 2006-01-18.
// Includes option to not apply cloak on the weekends.
// ==/RevisionHistory==
(function () {
// EDIT THE NEXT LINES TO SET THE HOUR AFTER WHICH SITES SHOULD APPEAR
// HOURS IN MILITARY TIME, SO 15 = 3PM
var surf_time_after = 15;
// TAKE OFF CLOAK ON WEEKENDS?
var cloak_off_weekends = true;
// END EDIT
var tstamp = new Date();
var its_the_weekend = false;
if (tstamp.getDay() == 6 || tstamp.getDay() == 0)
{
its_the_weekend = true;
}
var readable_time = ‘’;
if (surf_time_after > 12 )
{
readable_time = surf_time_after - 12;
readable_time = readable_time + ‘PM’;
} else {
readable_time = surf_time_after + ‘AM’;
}
if (tstamp.getHours() < surf_time_after )
{
if (cloak_off_weekends == true)
{
if (its_the_weekend == false)
{
var b = (document.getElementsByTagName(“body”)[0]);
b.setAttribute(‘style’, ‘display:none!important’);
alert(“You can surf after “+ readable_time + “; right ;
now, get back to work!”);
}
} else {
var b = (document.getElementsByTagName(“body”)[0]);
b.setAttribute(‘style’, ‘display:none!important’);
alert(“You can surf after “+ readable_time + “; right ;
34 Chapter 2 ■ Firewall Your Attention
now, get back to work!”);
}
}
})();
To change the time your Invisibility Cloak comes off, follow these steps:
1. Go to the script at http://lifehackerbook.com/ch2/cloak
.user.js. In Firefox, choose File → Save Page As. Save the script
to your computer, and then open the cloak.user.js file in a text
editor. Change the number 15 (which represents 3 p.m. on the
24-hour clock) in the line that reads var surf_time_after = 15;
to your desired time.
2. By default, the cloak is not applied on weekends. To change that setting,
edit the line that reads:
var cloak_off_weekends = true;
to
var cloak_off_weekends = false;
3. You can also change the message the cloak displays when you visit a
restricted site. Edit the line:
alert(“You can surf after “+ readable_time + ;;
“; right now, get back to work!”);
to include your custom message inside the quotation marks. (The
readable_time variable represents the time you set on the 12-hour
clock with AM or PM specified.)
4. Save your changes. In the Manage User Scripts dialog box, uninstall the
Invisibility Cloak. Then, open your edited cloak.user.js file in Firefox
and choose Install to use that version.
next day. You fire up a web browser to check the company intranet for a document.
For a split second you glance at your home page. “Wow!” you say. “The
Red Sox won in the 17th inning! Let me see what happened...”
Three hours later, no report’s been written, and you want to throw yourself
out the window.
Sound familiar?
It’s too easy to scamper down the rabbit hole of the Web when you’ve got
pressing tasks to work on. At one point or another, you’ve probably burned a
few hours clicking around Wikipedia, Amazon.com, eBay, Flickr, or Google
News and afterward hated yourself for it. This hack uses JavaScript to
blank out certain web sites during times you’re supposed to be working.
First, identify the biggest offenders — the sites you can spend hours clicking
around for no particular reason except boredom, procrastination, or lack of
more creative ways to spend your time..
To help yourself limit unproductive surfing, use this Invisibility Cloak user
script that turns time-wasting web sites blank before 3 p.m. (or whatever time
you configure). Here’s how to enable the Invisibility Cloak.
Install the Invisibility Cloak
The Invisibility Cloak JavaScript requires the Firefox web browser with the
Greasemonkey extension to run. Here’s how to get it set up.
1. Download and install the Greasemonkey Firefox extension from http://
greasemonkey.mozdev.org. (For detailed instructions on how to
install a Firefox extension, see Hack 71, “Extend Your Web Browser.”)
2. Using Firefox with Greasemonkey installed, go to the Invisibility Cloak
user script page at http://lifehackerbook.com/ch2/cloak
.user.js.
3. Click the Install button at the top right of the page
Set Which Sites Should Wear the Cloak
The Invisibility Cloak script is auto-configured to work on Metafilter
(http://metafilter.com) and Flickr (http://flickr.com), but you
want to it to work on the sites you choose.
1. In Firefox, select Tools → Manage User Scripts to edit, add, and remove
sites that should wear the cloak for you..
2. Use a wild card operator — the asterisk (*)— to indicate all pages on a
site. For example, http://flickr.com/* will apply the Invisibility
Cloak to all the pages on the Flickr.com domain.
3. When the Invisibility Cloak is enabled (the Enabled check box is
selected), visit one of the specified web sites before 3 p.m. and you get
the message.
Customize the Script
You can customize the Invisibility Cloak script further by hand-editing the
code. Following is the JavaScript body of the script. You’ll edit the bold lines in
a minute.
// Invisibility Cloak
// version 0.2
// Gina Trapani
// 2006-01-03
// Released to the public domain.
//
// ==UserScript==
// @name Invisibility Cloak
// @description Turns time-wasting web pages invisible until ;
a specified time of day; optionally on weekdays only.
// @include http://flickr.com/*
// @include http://*.flickr.com/*
// @include http://metafilter.com/*
// @include http://*.metafilter.com/*
// ==/UserScript==
//
// ==RevisionHistory==
// Version 0.1:
// Released: 2006-01-03.
// Initial release.
//
// Version 0.2:
// Released: 2006-01-18.
// Includes option to not apply cloak on the weekends.
// ==/RevisionHistory==
(function () {
// EDIT THE NEXT LINES TO SET THE HOUR AFTER WHICH SITES SHOULD APPEAR
// HOURS IN MILITARY TIME, SO 15 = 3PM
var surf_time_after = 15;
// TAKE OFF CLOAK ON WEEKENDS?
var cloak_off_weekends = true;
// END EDIT
var tstamp = new Date();
var its_the_weekend = false;
if (tstamp.getDay() == 6 || tstamp.getDay() == 0)
{
its_the_weekend = true;
}
var readable_time = ‘’;
if (surf_time_after > 12 )
{
readable_time = surf_time_after - 12;
readable_time = readable_time + ‘PM’;
} else {
readable_time = surf_time_after + ‘AM’;
}
if (tstamp.getHours() < surf_time_after )
{
if (cloak_off_weekends == true)
{
if (its_the_weekend == false)
{
var b = (document.getElementsByTagName(“body”)[0]);
b.setAttribute(‘style’, ‘display:none!important’);
alert(“You can surf after “+ readable_time + “; right ;
now, get back to work!”);
}
} else {
var b = (document.getElementsByTagName(“body”)[0]);
b.setAttribute(‘style’, ‘display:none!important’);
alert(“You can surf after “+ readable_time + “; right ;
34 Chapter 2 ■ Firewall Your Attention
now, get back to work!”);
}
}
})();
To change the time your Invisibility Cloak comes off, follow these steps:
1. Go to the script at http://lifehackerbook.com/ch2/cloak
.user.js. In Firefox, choose File → Save Page As. Save the script
to your computer, and then open the cloak.user.js file in a text
editor. Change the number 15 (which represents 3 p.m. on the
24-hour clock) in the line that reads var surf_time_after = 15;
to your desired time.
2. By default, the cloak is not applied on weekends. To change that setting,
edit the line that reads:
var cloak_off_weekends = true;
to
var cloak_off_weekends = false;
3. You can also change the message the cloak displays when you visit a
restricted site. Edit the line:
alert(“You can surf after “+ readable_time + ;;
“; right now, get back to work!”);
to include your custom message inside the quotation marks. (The
readable_time variable represents the time you set on the 12-hour
clock with AM or PM specified.)
4. Save your changes. In the Manage User Scripts dialog box, uninstall the
Invisibility Cloak. Then, open your edited cloak.user.js file in Firefox
and choose Install to use that version.
No comments:
Post a Comment