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.
- 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.
- 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.
- Get GreaseMonkey: https://addons.mozilla.org/en-US/firefox/addon/748
- GreaseMonkey User Scripts Repository: http://userscripts.org/
- GreaseFire automatically checks userscripts.org for scripts for current page https://addons.mozilla.org/en-US/firefox/addon/8352
- GreaseMetal is GM for Google Chrome, almost: http://greasemetal.31tools.com/
- JQuery. Easiest way to reach what you seek in the DOM: http://jquery.com/
- Firebug. Utterly essential FFox plugin for web development: http://getfirebug.com/
- "Dive Into GreaseMonkey" is a comprehensive, well-written, free online reference for GM: http://diveintogreasemonkey.org/toc/.
Kudos to Mark Pilgrim for this great resource.
Any readers out there using GreaseMonkey for business purposes?