[Greasemonkey] Three Minor Questions
pilgrim at gmail.com
Sat Feb 4 21:01:37 EST 2006
On 2/4/06, CBWhiz <cbwhiz at gmail.com> wrote:
> I'm writing a script that emulates on the following sequence:
> 1. User types captcha
> 2. User clicks button
> 3. page POSTs to another page
> 4. This page either holds 'error' or a link.
> Obviously, 1 and 2 are un-automatable. 3 takes place, which leads us to 4.
> This is the page I want to react on. I can sucessfully detect the
> 'error' condition - and on this paticular server the error is "we're not
> ready yet" - in other words, pressing F5 or hitting reload in about 10
> seconds corrects the error.
> To automate this, i tried location.reload(). However, Firefox asks, "Are
> you sure... POST data resubmitted...". I know that this is a security /
> stupidity feature, but is there any way to work around it? If i could
> get the current POSTed data I might be able to, but i'm not sure how i'd
> go about that.
This is tough, but doable. You'll probably need to run your script on
both pages -- the original form page and the submission page. On the
form page, trap the form submission, capture the form data before it's
submitted, and save it with GM_setValue. Start with the awesome Post
Then, on the submission page, if you detect the error condition, use
GM_getValue to retrieve your stored form data, and GM_xmlHttpRequest
to manually re-post it.
Lots of luck!
More information about the Greasemonkey