Bookmarklets for extracting form data (e.g. for POST forms in Plucker)

This page contains two bookmarklets.

Bookmarklets are little snippets of Javascript code designed to reside in your favorites or bookmarks or linklist or toolbar or whatever you call it. The idea is to store a bit of Javascript functionality so you can conveniently call it on a page where it is relevant.

Useage Scenario

The bookmarklets contained in this file are relevant to web pages that contain forms. The useage scenario is as follows:

You are on a web page with a form, and you wish to automatically submit this form in the future. For example, you may wish to provide the form data to the Plucker distiller so you can "pluck" the resulting page. For forms of method GET, you could simply submit the form and get the URL of the resulting page. For POST forms, this will not solve your problem.

Solution

First, you fill in the form. Then you select the bookmarklet from your bookmark list (or doubleklick on the link in your toolbar). A new window will open which contains all the information you need to pluck the form results page. You copy-and-paste that information into your plucker file and are done.

In the Plucker documentation you will find information on how to pluck POST forms.

Installation

There are two versions of this bookmarklet: One for POST forms, one for GET forms. I could have put both into one bookmarklet, but Microsoft limited their length to 508 characters in MSIE 6.0, so I had to conserve space. (Earlier MSIE versions had a much larger limit.)

You can install them by right-clicking on the link and selecting "add to favorites" or by dragging and dropping the link onto your toolbar or whatever is appropriate for your browser.

This web page also contains an example for a form, so you can test the bookmarklets.

Bugs and Features

The bookmarklets are tested with MSIE 6, MSIE 5.5 and Opera 7.2, so I don't really know if they work on other browsers. You'll have to test for yourself.

To make it work on MSIE 6, I had to trim it to less than 509 bytes (it is 507 bytes for the GET version, 504 for the POST version). Therefore, the script does no error checking. That is, if you use it with a file upload field, it will probably give you an error. There is still some slack, though: It is not strictly necessary to check for reset and button fields for most forms. (It does no harm if their values are sent to the server.)

Also, as is usually the case with bookmarklets, I had to obfuscate the code: It has to fit in one line, and variable names should not clash with names on the page where the bookmarklet is used. I used "jX" as a common prefix for all identifiers the bookmarklets use to avoid name clashes.

For shortening the code, I have resorted to a lot of with statements, unusual loop conditions in for loops and checking the field type only by two characters, not by the whole type. Also, I put most of the field types in the default branch of the switch statement.


1 2 3

2003-09-10, Jahn Rentmeister, see http://www.jahns-home.de/plucker.htm for more info and newest version. Report problems to <rentmei AT uni-muenster.de> with "Bookmarklet" in the subject line.