Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:17:47+00:00 2026-06-12T05:17:47+00:00

I want to submit a form in a page using a Greasemonkey script. The

  • 0

I want to submit a form in a page using a Greasemonkey script.
The name and pw in the form is remembered by Firefox, so when the page is loaded, the name and pw are already filled. So just want a submit to auto login.

The form code:

<form class="enableAutoFocus" method="post" id="login_form" action="http://localhost/plan/login_form">
    <div id="login-form">
        <input name="came_from" value="" type="hidden">
        <input name="next" type="hidden">
        <input name="ajax_load" type="hidden">
        <input name="ajax_include_head" type="hidden">
        <input name="target" type="hidden">
        <input name="mail_password_url" type="hidden">
        <input name="join_url" type="hidden">
        <input name="form.submitted" value="1" type="hidden">
        <input name="js_enabled" id="js_enabled" value="0" type="hidden">
        <input name="cookies_enabled" id="cookies_enabled" value="" type="hidden">
        <input name="login_name" id="login_name" value="" type="hidden">
        <input name="pwd_empty" id="pwd_empty" value="0" type="hidden">
        <div class="field">
            <label for="__ac_name">Login Name</label>

            <input style="margin-right: 0px; padding-right: 0px;" size="15" name="__ac_name" value="" id="__ac_name" type="text"><img title="Max field length is unknown" style="position:relative; z-index: 999; cursor:pointer; vertical-align: bottom; border: 0; width: 14px; height: 19px; display:none;" class="ife_marker" src="chrome://informenter/skin/marker.png" id="__ac_name_ife_marker_1">
    </div>
    <div class="field">
            <label for="__ac_password">Password</label>
            <input style="margin-right: 0px; padding-right: 0px;" size="15" name="__ac_password" id="__ac_password" type="password"><img title="Max field length is unknown" style="position:relative; z-index: 999; cursor:pointer; vertical-align: bottom; border: 0; width: 14px; height: 19px; display:none;" class="ife_marker" src="chrome://informenter/skin/marker.png" id="__ac_password_ife_marker_2">
    </div>
        <div class="formControls">
            <input class="context" name="submit" value="Log in" type="submit">
        </div>
    </div>
</form>

On the page the first form is a search form, so first I tried document.forms[0].submit();
It works.

Then I change the code to:

document.forms[1].submit(); 

The error console reports:

Error: document.forms[1].submit is not a function

Then I searched, and found the following code and tried it.

function ClicktheButton(obj) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
  0, 0, 0, 0, 0, false, false, false, false, 0, null);
 var canceled = !obj.dispatchEvent(evt);      
 }
 var StupidButton = document.querySelector('input[type="submit"][value="Log in"]');
 ClicktheButton(StupidButton);

The click function works, but the name and pw are blank, so the login is not accepted.

Could someone do some explain and help? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:17:49+00:00Added an answer on June 12, 2026 at 5:17 am

    It takes a little bit of time for the browser to fill in the username and password.
    When the page first loads and the Greasemonkey script fires, they are still blank in that instant.

    So you need to wait for these fields to be filled. Something like this:

    var numIntervals    = 0;    
    var pwFilledTimer   = setInterval ( function () {
            var usrNameInp  = document.getElementById ("__ac_name");
            if (usrNameInp  &&  usrNameInp.value != "") {
    
                var passWrdInp  = document.getElementById ("__ac_password");
                if (passWrdInp  &&  passWrdInp.value != "") {
    
                    clearInterval (pwFilledTimer);
    
                    var submitButton = document.querySelector (
                        'input[type="submit"][value="Log in"]'
                    );
                    var clickEvent  = document.createEvent ('MouseEvents');
                    clickEvent.initEvent ('click', true, true);
                    submitButton.dispatchEvent (clickEvent);
                }
            }
            numIntervals++;
            if (numIntervals > 10) {
                /*--- Stop the timer after about 2 seconds so it doesn't 
                    interfere with manual logins.
                */
                clearInterval (pwFilledTimer);
            }
        },
        200
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to submit a form without page refresh using jQuery. I found some
I have a simple form on a page and I want to auto submit
Let's say I'm at http://www.domain.com/page.html . I want to submit this form: <FORM METHOD=post
I have a form on a non-SSL page that I want to submit as
i want to submit a form using Ext.Direct and iam following all the guidelines
I want to submit a form that have many checkboxes with different values, using
I want to submit a form using jQuery in a CodeIgniter application. However, the
I am using php/ajax to submit a form without page refresh. Here are my
I want to debug a form submit using netbeans but cannot find the option
Any way to submit a form without refreshing the current page at all using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.