Drop everything and listen to this week's Gadling Podcast in which Erik interviews James O�Reilly, the publisher of Travelers� Tales. Right mouse click and save the 21MEG MP3 file .


Greasemonkey: Hacking the Web with JavaScript

When Adrian Holovaty had enough of various problems with AllMusic’s site, he decided to fix it himself—he wrote a Firefox extension that fixed the site for himself and anyone who installed the extension. Now anyone can do it—with a new Firefox extension called Greasemonkey, all you have to do is write the script, and the extension manages multiple site-specific scripts.

For example, I’ve been frustrated recently by a bug in Bloglines, my RSS aggregator of choice. Read on to find out how I solved the problem using Greasemonkey and one line of JavaScript, and it should give you an idea of how you can use the same technique with other sites. (This is a long one!)

Update 1/17/2005: Bloglines has fixed the bug in question, so while the tutorial below still shows how to use Greasemonkey in general, the specific fix I mention isn’t necessary.

First of all, you’ll need Firefox to do this, and you’ll need to install the Greasemonkey extension from this page. Now here’s my specific example:

Bloglines bug
Here’s the problem. When I try to save a clipping, the description (in the textarea above) includes extraneous HTML, which ends up cluttering my clip list. I want it to simply contain the name of the item, just like the text field at the top of the form. So if we could just copy the value of the text field to the textarea, the problem would be solved.

First, we need to know the names of the form fields. You can view source to do this, but I like to use the Web Developer Extension toolbar. It turns out the name of the form is saveform, the text field is postEntryTitle, and the text area is notes. We also need to know the URL of the page. Since it’s a pop-up, right-click on it and select View Page Info.

Greasemonkey can execute a script after the DOM is loaded, and before the onLoad event, which is a perfect place to copy the form data. The script we’ll need is a one-liner:

document.saveform.notes.value = document.saveform.postEntryTitle.value;

Type this line (it should be one line, remove any linebreaks) into a text file and save it as fixbloglines.user.js. The .user.js portion identifies it as a Greasemonkey user script. Next, open the script in Firefox (or click on mine) and select Tools | Install User Script from the menu. The Greasemonkey extension displays a dialog:

Click Add and add the URL http://www.bloglines.com/saveitem* to the Include list, and then remove the wildcard item (*) - that way the script won’t wreak havoc with any other site you visit.  Click OK and we’re done!

After the script is installed, Bloglines suddenly behaves, as shown below. You can use the Options button next to Greasemonkey in the Extensions dialog of Firefox to modify the settings or remove a script. Good luck!

Bloglines bug2

Permalink | Email this | Comments [4]

Recent Entries

 » sIFR 2.0 RC4 released (2/28/2005)
 » Ajax: You’re soaking in it (2/28/2005)
 » Stuart Langridge joins Sitepoint (2/28/2005)
 » Yet more on Google Maps (2/28/2005)
 » Housekeeping: Back from vacation (2/28/2005)

(Add your comments)

Reader Comments

1. Posted Jan 8, 2005, 2:50 PM ET by Kristen

This looks rather promising. If only I could figure out how to hide the flash advertisement on the left side of http://www.relevantmagazine.com so that Firefox doesn't crash (it crashes if I leave this page open and open other links).

2. Posted Jan 8, 2005, 5:07 PM ET by Aaron

Kristen, does this script fix your crash problem?


3. Posted Jan 9, 2005, 2:06 PM ET by Scott Kingery

The way you block the ad is to first get Firefox then get the Ad Block extension. It makes browsing SO much faster. Read all my tips at: http://tinyurl.com/5csxt

4. Posted Jan 22, 2005, 2:24 PM ET by Kristen

Thanks Aaron! I just looked back at this entry now, and that script worked. I appreciate it!

Add your comments

Please keep your comments relevant to this blog entry: inappropriate or purely promotional comments may be removed. Email addresses are never displayed, but they are required to confirm your comments. To create a live link, simply type the URL (including http://) or email address and we will make it a live link for you. You can put up to 3 URLs in your comments. Line breaks and paragraphs are automatically converted — no need to use <p> or <br> tags.

Do you want us to remember your personal information for next time?




Get your own text link here.


(past 60 days)


Blogging Baby
hack a day
pPlayer (poker)
TUAW (Apple)
Apple (Unofficial)
Digital Photography
Flash Insider
Google (Unofficial)
Grid Computing
Microsoft (Unofficial)
Open Source
Photoshop (Unofficial)
SAS (Unofficial)
Search Engine Marketing
Social Software
Tablet PCs
Yahoo (Unofficial)
BBHub (BlackBerry)
Engadget: Cellphones
Engadget: GPS
Ultra Wideband
The WiMAX Weblog
Engadget: Wireless
Wireless Dev
Video Games
Blogging E3
Engadget: Gaming
Playstation 3
Video Games
Xbox 2
Media & Entertainment
Digital Music
Documentary Film
Droxy (Digital Radio)
Independent Film
Magazine Design
The Mortgages Weblog
SCM Wire (supply chain)
Life Sciences
The Cancer Blog
The Diabetes Blog
Medical Informatics
Brian Alvey
Jason Calacanis
Blog Maverick
Gordon Gould
Judith Meskill
Blogging DEMO
Blogging E3
Blogging ETech
Future of Music
Blogging Milken
Blogging Sundance
Blogging Web 2.0
Weblogs, Inc.

The JavaScripte Blog is part of the Weblogs, Inc. Network — a network of more than 70 blogs.
Here are some recent headlines from our other blogs:

Lexus site “down”
That was fast: More Lexus IS info
Lexus IS 250/350: First glimpse, maybe
Ralph Lauren’s entrancing exhibit
Mass transit sometimes a pleasant alternative to driving

Luxist (fine living)
Oscar Jewels for the Gents
Modphone Service
Irish Whiskey Cigars
De Gournay Wallpapers
The Dark Side of Oscar Freebies—Taxes

hack a day
hackaday links
covert desk lamp mic
xbox landing lights mod
rfid dartmail
homebrew mac mini dock
Joystiq (video games)
Ubisoft breathes new life into Microsoft’s deceased sports franchises
Celda detractors, taunt no more!
True Crime 2 screenshots from PS3 and Xbox 360?
FIFA Street = bad idea?
Tablet PC turned portable gaming device - The Rogue
Blogging Baby
10 ways to save money on baby gear
Surgeon General says no amount of alcohol is safe during pregnancy
RC2 Corp. recalls bottle warmers
Is it time for a MomTini?
New reality TV hit: The un-Vasectomy!
Gadling (travel)
The Works of Ana Mendieta
Fossett on Another Grand Adventure
Cool Canadian Arctic Cruises
Genealogy Trips - A Family Affair
Early Black Explorers
Creative Commons releases license breakdowns
Ex-Loki Users Have Little to Fear
A DNS system for file on P2P networks
Earthstation 5 signs off the P2P airwaves
UK downloaders avid for US TV content
Application Allows Barcode Scanning With A Bluetooth-Enabled Blackberry
Not So Fast, Wireless Services Growth!
ZigBee-Based Meter Reading System Could Save Utilities Big Money
A Call For An End to the UWB Standards Battle
SONbuddy Helps You and Your Pals Setup Your Own Wireless Network
Indie Film
Memeroll: A Scanner Darkly Trailer
Post-Oscars Party Talk
Brooooooooooooklyn!!! (or, How did Chris Rock do?!?)
And Best Picture Goes To …
Flash Insider
Classic Flash Learning
Educational Flash
Exceptional Math
Optimization ala FITC 04
Need for Interaction
TUAW (Apple)
Apple goes to work
Freeware February: Recapping the Month that Was
iPod DJing hits the States; what’s in an iPod name?
Freeware February: Markdown

The Rogue gaming tablet PC
Major labels want you to pay more for legit music downloads
CoolP3: portable audio for preschoolers
A next-gen Game Boy by Xmas?
Flower Robotics Inc.’s Palette robo-mannequin

If you want to advertise on the largest blog network in the world,
email Shawn Gold or call him at 310-828-8284.