My pretty face [ László Monda's Blog ]
Exploring the cyberspace, one quadrant at a time!
 
Main Page | Blog | Projects

Archive for May, 2007

How to Automatize HTTP Requests Using Greasemonkey

Thursday, May 31st, 2007

There are some sites that I use daily. The sad thing is, many of them don't provide me any mechanisms to log in automatically, so I have to always do it manually. I also had to fill the same form in on these sites and carry on the same operation over and over again. This was very frustrating for me so I decided to come up with a solution. Greasemonkey seemed to have the potential to solve my burning need.

I want to share the core function I've written that can help you in such scenarios. It's a simple, but very useful one.

function submit_form(method, action, elements, target)
{
    var form = document.createElement('form');
    document.body.appendChild(form);
    form.method = method;
    form.action = action;
    for (element_i in elements) {
        var element = document.createElement('input');
        element.setAttribute('type', 'hidden');
        element.setAttribute('name', element_i);
        element.setAttribute('value', elements[element_i]);
        form.appendChild(element);
    }
    if (target) {
        form.target = target;
    }
    form.submit();
}

Requests are typically triggered based on the content of window.location.href or document.referrer.

Greasemonkey has some ugly annoyances, but fortunately most of them can be worked around. The LiveHTTPHeaders add-on can also help you tremendously constructing the fields of the forms.

Links for 2007-05-31

Thursday, May 31st, 2007

Links for 2007-05-30

Thursday, May 31st, 2007
  • Microsoft's top-secret touch screen - Ok, I fucking hate Microsoft, but there are some great usability ideas in this video. Very creative use cases, seems so much fun to interact with such an interface.

The Vanished Preview Frame

Wednesday, May 23rd, 2007

In WordPress 2.1 there was a UI element on the post page called the preview frame. This was basically an iframe that let you preview your post right on the post page. It was very convenient and I used it every time. Shockingly upon upgrading to WordPress 2.2 I couldn't find it. I was being told on #wordpress that it was removed in WordPress 2.2.

I didn't understand why it was removed so I asked developers on the mailing list. I managed to start a long thread about the issue. I realized that the preview frame was rather disturbing for most folks. Fortunately my issue got solved by the extraordinary Rob Miller in the form of a nifty plugin that implements the preview frame.

Thank you very much Rob! You've made my life easier.

Links for 2007-05-22

Tuesday, May 22nd, 2007

Links for 2007-05-20

Sunday, May 20th, 2007

The Three Ages of The Developer - Yet another article of pure wisdom from Hacknot.

Symlinker 0.0.2 Released

Sunday, May 20th, 2007

It's a small bugfix release.

Symlinker 0.0.1 Released

Wednesday, May 9th, 2007

I've just released Symlinker 0.0.1. Symlinker is a minimalistic PHP file manager that is built to primarily operate with symlinks. Read more about it on its project page.

Links for 2007-05-07

Monday, May 7th, 2007