We use cookies. You have options. Cookies help us keep the site running smoothly and inform some of our advertising, but if you’d like to make adjustments, you can visit our Cookie Notice page for more information.
We’d like to use cookies on your device. Cookies help us keep the site running smoothly and inform some of our advertising, but how we use them is entirely up to you. Accept our recommended settings or customise them to your wishes.
×

GreaseMonkey: Hacking Web Apps So They Work The Way YOU Want

GreaseMonkey is a Firefox extension that lets you run arbitrary Javascript code against selected web pages.

greasemonkey2What this means is that GreaseMonkey lets you change how other people's web pages look and how they function (but just in your own browser, of course).

I last played with GreaseMonkey (GM) about four years ago. Then, I didn't find the idea compelling. Today, with ever more applications going online, GM is worth a serious look.

GM can increase productivity by making web apps easier to use.

Even more interesting, GM also lets you add functionality to web pages. Here's a small example. I use Delicious to bookmark sites. I used Google Reader to read blogs, and I tag interesting posts with Reader's "gold star" button. Via a few lines of GM code, Google Reader now sends my starred items to Delicious automatically. This improvement keeps all my interesting links in one place.

GM works on intranets, too.

Suppose you're an online retailer and your merchants use an intranet app to enter product information for your site. Suppose that app had some UI annoying issues, like extra confirmation screens after entering each product ("Are you sure you want to add the following?") If your vendor or your internal IT folks can't (or wont) change the app, you could use GM to skip the unnecessary page.

Or perhaps your call center staff uses an intranet app for order entry. If they're retyping or pasting telephone data from phone pop into the order entry app on each call, perhaps the phone app could write its data to a local file (maybe) which GM then used to prepopulate fields in order app.

A GM script could even prepopulate web app fields from database lookups (you'd need to expose the necessary data via some simple restful url, behind the firewall).

Certainly hacky, certainly not 'beautiful' engineering, but GM opens up interesting possibilities.

Here are the GM pros and cons as I see them.

Pros:

  • Javascript. GM code is just Javascript code. Any developers familiar with Javascript and the DOM can write GM scripts.
  • User scripts. If you're seeking a common sense improvement to a popular site, someone probably has already written a GM script to do it. For example, here are popular scripts tweaking Google sites.
  • Cross-site scripting. Unlike the security model in common AJAX, GM code can access the entire web: "Unlike the XMLHttpRequest object, GM_xmlhttpRequest is not restricted to the current domain; it can GET or POST data from any URL" (from DiveIntoGreaseMonkey). This is very powerful.

Cons:

  • Scraping stinks. Fundamentally, GM is screen-scraping. Yuck. If your target site changes their design, your GM script probably croaks.
  • Ffox preferred. GM runs best in Firefox. Some GM scripts run on Chrome, but some do not. (Specifically Chrome does not support the GM_ functions, including GM_xmlhttpRequest.). Here's info on the "--enablegreasemonkey" flag in Chrome, and here's info on GreaseMetal . I've not used it, but IE has GM4IE.
  • Reality warp. If you forget you have GM turned on, or if you assume GM is on when it isn't, or if you switch to a computer without GM, you can get confused when a familiar web page behaves "strangely."
  • Debugging. Sometimes it is hard to understand why a GM script isn't working. Firebug is essential.
  • Local install. The GM extension and scripts are installed locally, not in the cloud. Installing them on your laptop doesn't put them on your desktop, etc. Script updates need to be maintained on each machine.

And here are some GM links I found useful.


Any readers out there using GreaseMonkey for business purposes?

greasemonkey