Mr Speaker

Web automation with Chickenfoot

ChickenfeenI was getting scared there for a minute. It had been at least a few weeks since I last found something on the interweb that rocked my web-based world.

Things were getting desperate, and for a moment I feared I might be forced to go back and work on one of my half-finished projects or something. But I was saved. Saved by the crunchy goodness of Chickenfoot. Yes, Chickenfoot will (slightly) change your life.

Chickenfoot must be compared to Greasemonkey. Indeed, from the vague description I was given at Sydney BarCamp (I was told the wrong session time, and missed the actual demo) I assumed it was just someone re-inventing the monkey.

But I was wrong. Slightly wrong.

Chickens vs. Monkeys

Like Greasemonkey, Chickenfoot lets you mess with web pages on the client side: Correct bugs, fix annoyances, create new functionality... whatever you want - without having to ask the site admins to lift a finger.

The main difference between the chicken and the monkey is that Greasemonkey primarily operates on a page-by-page basis, where as Chickenfoot scripts run as a single transaction involving multiple pages - even spanning multiple sites.

This makes it more suited for automating repetitive processes, rather than tweaking DOM elements. (Note I said "more suited" - Chickenfoot can do some fancy tweaking, just as Greasemonkey can work as a process automater.)

Scripting for the people

The other big difference is that Chickenfoot has tried to target the non-techy user. Here is an example of a Chickenfoot transaction:

go("google.com")
enter("Mr Speaker")
click("google search")

No prizes for guessing what that script does. Well, it's not that obvious, I just don't have any prizes. Chickenfoot acts like a real life user - the commands get executed as if a user had done them: go("google.com") navigates to google.com, enter("Mr Speaker") types Mr Speaker into the text box, and click("google search") simulates a click on the button called "google search". The result is your browser opened on the Google search results page having done a search for "Mr Speaker". Pretty cool hey?

As you can see they've tried to make it nice and friendly. Though, it really only stays friendly while you are trying to do pretty simple stuff. It doesn't take long until you find yourself DOM-inspecting to get element names, or writing some funky regular expressions to extract data - something that the developers are trying to avoid you having to do.

But the built in functions are quite powerful. The wrapper functions (like go, enter, click, pick, check) do more than just a simple document.location, button.click(), item.select()... they fire events, and wait for callbacks - so you don't have to! In the above example, the line to enter some text in a text box does not occur until the page load from the line before has completed. This makes writing Chickenfoot scripts damn fun!

Where it can be used

Chickenfoot scriptLike all these cool gadgets, they are only useful if they actually solve a problem. The problem that Chickenfoot is best at solving usually goes along the lines of "To get to the information I need I have to log in, then select this from that dropdown box, then check that checkbox and then click here. Then click here. Then there. And that's the screen I want."

Chickenfoot can automate all those steps, and then take you to your final destination. Or better still, automate all those steps, do a bit of screen-scraping, and display the data somewhere else without you having to go to the site at all!

If you are doing web dev work, it's the best thing since the Web Dev Toolbar... You can automate EVERYTHING; automatically log yourself into all your apps and display a status update of your flickr/twitter/blah blah accounts. Automate all your forms testing, bug tracker updates and time sheet entries. Add your RSS feeds into the company intranet so it looks like you're actually working.

Then with a press of the button, your awesome time-saving scripts can be converted to standalone Firefox extensions which you can distribute to co-workers and receive accolades from your bosses. Or be fired by your bosses.

How it changes things

Chickenfoot has a chance to change things considerably. As more desktop applications are being accessed by web-based front-ends, this kind of automation can help streamline business processes and remove user frustrations.

If users begin writing thier own scripts that become popular within a department, they could be flagged to the dev team as a possible system enhancement. Alternatively, annoying users who demand stupid functionality changes could be appeased with a couple of lines of code.

It also probably presents severe security implications that we won't worry about right now.

Get to it

In conclusion: have a go. Chickenfoot is currently buggy and confusing, but inspirational and time-wastey. It will fill your head with ideas that I'm sure you'll never implement. That's what Web2.0 is all about.

The Chickenfoot documentation is pretty atrocious, so I'm in the processes of writing up a lil' tutorial for you all. But that won't be done until I've written a few Chickenfoot scripts that I can't believe I've had to live without all this time...

7 Comments

  1. Copy-pasting is a thing of the past. I think you just freed me from minutes of work a day!

    Monday, April 2, 2007 at 3:43 pm | Permalink
  2. I’ve been loving Chickenfoot too – subbed to the mailing lit for many months but I didn’t actually use it for anything until last week, when I wrote an Amazon wishlist scraper

    Given a choice, I will always use XPath to get at the useful bits of web pages rather than DOM tree crawling or regexps and Chickenfoot’s handling of XPath is pretty nice (very simple to use), except for the fact that you can currently only use it to get a handle on DOM elements and ranges, though going the last step to an attribute value or a text childNode is pretty straightforward.

    You can still use Firefox’s XPath implementation in your Chickenfoot scripts, of course.

    Monday, April 2, 2007 at 5:53 pm | Permalink
  3. Chickenfoot is fine but you should try iMacros from
    http://www.iopus.com/imacros/firefox/

    I have used iMacros for some months now and found it extremely useful.

    Neil

    Tuesday, April 3, 2007 at 7:15 pm | Permalink
  4. Hmmm, that looks kinda interesting, but has things like “Purchase now!” and “Patents Pending” written all over it. And sheesh, don’t call them “macros” – us web guys are just starting to pretend we are real programmers!

    p.s. I’m loving chickenfoot even more now that I’ve got the Greasemonkey include workin’ away – it’s sooooo made for script junkies like me!

    Tuesday, April 3, 2007 at 8:02 pm | Permalink
  5. Do you think some of the big player will start to scripting for it like they did greasemonkey?
    Is anyone else put off by over simplified scripting languages?

    Thursday, April 5, 2007 at 9:19 am | Permalink
  6. I’ve been using this tool. It’s really nice.

    Saturday, April 28, 2007 at 6:59 pm | Permalink
  7. I first used imacros addon for firefox then jumped into the world of greasemonkey but chickenfoot it’s just what imacros and greasemonkey needed – more user power and advanced customization – I would predict chikenfoot would become more popular than greasemonkey or maybe they’ll somehow morph eachother.

    Saturday, March 20, 2010 at 4:35 am | Permalink
Captcha! Please type 'radical' here: *
How did you find this thingo? *