Javascript: How-To auto-submit a form

15,243 views
Skip to first unread message
Message has been deleted

cudd...@gmail.com

unread,
May 10, 2015, 11:24:32 PM5/10/15
to chrome-...@googlegroups.com
Thought I would cobble together a quick little guide to help people who have little to no experience with JavaScript and how they could use it to auto-click a login button.

--------------------------------------------------------------
IMPORTANT TO REMEMBER!
While reading this, please remember that the more specific information you provide the JavaScript, the better. Otherwise the JavaScript rule might trigger accidentally because it thinks it found what it needs to click/submit again and do it over and over again.
--------------------------------------------------------------

First you have to add a rule - Please note that this must be the 'last' rule in any profile so it is the last thing fired, otherwise it will click the button before you would want it to.

1. Set the 'Type' of this rule to JavaScript
2. Now the 'Name' field will be greyed out, don't worry about that.
3. The 'Value' field is where you will shove the actual JavaScript.

This is a general line that you can copy and paste which should cover most use cases (it works for all my profiles, and I have a fair few): document.querySelector('form[name="<insertvaluehere>"]').submit();
The only important thing you will ever need to edit in this line is: form[name="<insertvaluehere>"]

--------------------------------------------------------------

Now, for each site you will need some information to help make this line work for you. All chrome browsers have a functionality that if you right-click on something you will get an 'inspect element' option. Do this on the button you would normally click on to login and you will get a little window that says 'Developer Tools' and it will have a bunch of source code in it.

Initially the thing you right-clicked on will be highlighted, so you should just be able to press the left arrow key on your keyboard and it will collapse the tree until you reach a tag that starts with: <form

As an example I will copy and paste the '<form' tag part from accounts.google.com:
<form novalidate="" method="post" action="https://accounts.google.com/ServiceLoginAuth" id="gaia_loginform">

I will provide three examples that will submit this form.

document.querySelector('form[method="post"]').submit(); -> Using this one is probably a bad idea because it has very low specificity, meaning every time autofill finds a form that matches this ANYWHERE on the google site, it will submit. This could be a search form, or a subscribe form, or whatever.

document.querySelector('form[action="https://accounts.google.com/ServiceLoginAuth"]').submit(); -> This one is most likely quite good because I doubt there is another form on the google site that would match this (and result in a 'false submit')

document.querySelector('form[id="gaia_loginform"]').submit(); -> This one is best because in HTML ID's are supposed to be unique, so the chances of them existing anywhere else on the site are very slim.

As you can probably guess by now you just edit what is in the square brackets to match whatever is in the form tag. All form tags are formed differently and may have different values inside them, but the JavaScript provided should be able to match them regardless.


--------------------------------------------------------------
EXTRA STUFF IF YOU WANT TO LEARN
--------------------------------------------------------------
form[id="gaia_loginform"] -> Technically this is essentially finding a HTML tag and the following attribute it contains.

A HTML Tag is basically anything after an opening left triangle: <
HTML Tag examples:
                      <div
                      <input
                      <form
                      <whatevertheHTMLSourcesays

Attributes are what come after the tag name and before the first right triangle you encounter: >
Attribute examples:
                      id="yay">
                      class="peanutbutter">

So, <cheeseburger id="yay"> would be matched by writing: cheeseburger[id="yay"] into the JavaScript code line above.
--------------------------------------------------------------
.submit() -> This is a JavaScript function that will submit your form.

If the site you are using doesn't use a form to submit (for whatever reason) you might have to use .click() instead.

Right-click on the button you would normally click on to login and 'Inspect Element'. The window opened will have the element highlighted for you, and basically using everything you know so far you can now target something to .click()

jamie.broa...@googlemail.com

unread,
May 29, 2015, 8:03:00 PM5/29/15
to chrome-...@googlegroups.com, cudd...@gmail.com
Hi,
How about on this website 'http://www.supremenewyork.com/shop/all' how would i click one of the images/items? and then navigate to the checkout stage. Thank you very much

Stanley Denman

unread,
Aug 16, 2016, 6:24:25 PM8/16/16
to Autofill Chrome Extension, cudd...@gmail.com
I am trying to figure out a way to populate government forms with data from my Microsoft Database.  What you are talking about here seems like it might be the approach I need.  I have gone through completing my forms a creating a profile, then I can export the profile csv file.   If i now just had that document as a "template" with fields that could be filled from my database I think I might be in business..Any ideas..Thanks.

glenn nall

unread,
Oct 28, 2016, 9:07:50 PM10/28/16
to Autofill Chrome Extension, cudd...@gmail.com
Very nice, thank you for your efforts!!!

pie...@gmail.com

unread,
Dec 27, 2016, 7:34:07 AM12/27/16
to Autofill Chrome Extension, cudd...@gmail.com
I'm trying to find out what to write for clicking the Paypal Button on https://www.hanon-shop.com/basket ...can anyone help me? I'm sure i tried out everything

shadow...@gmail.com

unread,
Dec 1, 2017, 2:51:25 AM12/1/17
to Autofill Chrome Extension


在 2015年5月11日星期一 UTC+8上午11:24:32,Cuddly Cow写道:
i use document.querySelector('input[id="btnSubmit"]').click(); and it works well, however the web load every second automaticly, i dont know why, is it need to add some stop codes?

joleh...@gmail.com

unread,
Dec 18, 2017, 6:58:13 AM12/18/17
to Autofill Chrome Extension
This worked for me if anyone is having trubbel this works

document.querySelector('[id="submit-orderstatussearch"]').click(); 

Shadow Melanch

unread,
Jan 15, 2018, 10:39:15 PM1/15/18
to chrome-...@googlegroups.com
thx, i will try it😀

On Mon, Dec 18, 2017 at 7:58 PM, <joleh...@gmail.com> wrote:
This worked for me if anyone is having trubbel this works

document.querySelector('[id="submit-orderstatussearch"]').click(); 

--
You received this message because you are subscribed to a topic in the Google Groups "Autofill Chrome Extension" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/chrome-autofill/ZrR7MyVhq8o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chrome-autofill+unsubscribe@googlegroups.com.
To post to this group, send email to chrome-autofill@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chrome-autofill/31b010f6-7ab8-4080-bbbe-5da5860d35bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Velatne

iwil...@gmail.com

unread,
Jun 13, 2018, 6:56:56 PM6/13/18
to Autofill Chrome Extension
Thanks a bunch for this how to.
One question... Maybe two.

Is there a way to make one of these rules automatic on a given page and not on another page?

Here for example... Link below.
I always click on For Sale By Owner. On the page after it often varies. So an auto click wouldn't be wanted.

https://post.craigslist.org/k/QE4SVlpv6BGTZzJxJAxAsg/SSUl5?s=type

Also I post stuff for sale on Facebook too.
Was looking at doing some auto button scripts there today but noticed when I right clicked any where on Facebook with Chrome no "Inspect" dialog came up. Not an option. Is there another way or is this just another lousy "Facebook fix"?

Thanks again.

BTW... Gonna ask the main programmer about selective auto/manual. Per rule. Not extension wide. If that's possible.

Message has been deleted

carlos bolivar

unread,
Jan 11, 2019, 5:29:25 AM1/11/19
to Autofill Chrome Extension
Good morning I could help with the field "value" for these three buttons do not know anything Java Script, I need help thanks ...

<a target="linked_search_title" href="https://www.linkedin.com/in/neil-rowan-52857316" class="btn btn-success"> Neil Rowan's LinkedIn Page </a>
<input type="submit" class="submit btn btn-cf-blue" value="Submit &amp; Continue">
<input type="submit" name="commit" value="Sign In" class="btn btn btn-primary">

psych...@emailn.de

unread,
Jan 11, 2019, 12:42:01 PM1/11/19
to Autofill Chrome Extension
Hi, the 3 examples from cuddly cow are not working for me. Modify this for your buttons. Try this

document.querySelector('input[value="Sign In"]').click(); 

willowa...@gmail.com

unread,
Jan 18, 2019, 8:14:10 AM1/18/19
to Autofill Chrome Extension
I am trying to add autofill to the website waitwhile.com, but can't seem to make it work on the actual list I am wanting to sign up on. Do I have to go into every website that I want to use autofill on and add it to my extension? Thanks in advance!

faisal...@gmail.com

unread,
Apr 26, 2019, 3:42:29 PM4/26/19
to Autofill Chrome Extension
i press inspect button and this appears to me .. what i type in value column ?
Screen Shot 2019-04-25 at 8.03.09 AM.png
Screen Shot 2019-04-25 at 8.03.17 AM.png

Mosbah Abdelouahab

unread,
Apr 26, 2019, 11:27:49 PM4/26/19
to chrome-...@googlegroups.com
document.querySelector('yourSelector').click();


Garanti sans virus. www.avast.com

Le ven. 26 avr. 2019 à 20:42, <faisal...@gmail.com> a écrit :
i press inspect button and this appears to me .. what i type in value column ?

--
You received this message because you are subscribed to the Google Groups "Autofill Chrome Extension" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chrome-autofi...@googlegroups.com.
To post to this group, send email to chrome-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chrome-autofill/e6e26cb2-5cc8-4f34-bd74-fb7fb12c27b0%40googlegroups.com.

Faisal AJ

unread,
Apr 27, 2019, 2:31:35 AM4/27/19
to chrome-...@googlegroups.com
What i type in (your selector) ?

You received this message because you are subscribed to a topic in the Google Groups "Autofill Chrome Extension" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/chrome-autofill/ZrR7MyVhq8o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chrome-autofi...@googlegroups.com.

To post to this group, send email to chrome-...@googlegroups.com.

insy...@gmail.com

unread,
May 8, 2019, 5:51:14 PM5/8/19
to Autofill Chrome Extension
Hello, I've tried all the variations from this post as well as help file, but it just won't work. The button won't click no mater what I do :(

<input type="submit" name="btnSaveDocument" value="Save" onclick="return validateSave();WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;btnSaveDocument&quot;, &quot;&quot;, true, &quot;LogDocument&quot;, &quot;&quot;, false, false))" id="btnSaveDocument" class="button">

Any ideas how I can get the button to click?

This is what I tried but it didn't work:


document.querySelector('[type="submit"][value="Save"]').click();

document.getElementByID('btnSaveDocument').click();

document.querySelector('#btnSaveDocument').click();

var eClick = new Event('click', {'bubbles':true});
document.getElementById('btnSaveDocument').dispatchEvent(eClick);

document.querySelector('form[id="form1"]').submit();

document.querySelector('[id="btnSaveDocument"]').click();

document.querySelector('input[id="btnSaveDocument"]').click();

document.querySelector('input[value="Save"]').click();
Message has been deleted
Message has been deleted

Tebla Tozo

unread,
May 22, 2019, 7:06:52 AM5/22/19
to Autofill Chrome Extension
i need to fill a field by random company name. is there any way so i can store some huge company name and it will fill the field when i am in that website. someone please help me.

السعيد عبد الحفيظ

unread,
May 26, 2019, 9:41:24 AM5/26/19
to Autofill Chrome Extension
السلام عليكم،
توجد طريقة لمل الحقل باسم شركة عشوائي ، إبعث لي الموقع وسوف أحاول مساعدتك.

Tebla Tozo

unread,
Jun 5, 2019, 7:43:40 AM6/5/19
to Autofill Chrome Extension
Hello everyone. i need to figure out some field. i posted it and no reply yet. so i need AutoFil expert to help me. my Skype is asdakash . please add me if you are good in Autofill, i will pay you for your help. thanks

FuN DuDe

unread,
Jun 5, 2019, 10:41:00 AM6/5/19
to chrome-...@googlegroups.com
Yes. But which programing to use auto fill.. then i help you ...

On Wed 5 Jun, 2019 5:13 pm Tebla Tozo, <khanni...@gmail.com> wrote:
Hello everyone. i need to figure out some field. i posted it and no reply yet. so i need AutoFil expert to help me. my Skype is asdakash . please add me if you are good in Autofill, i will pay you for your help. thanks

--
You received this message because you are subscribed to the Google Groups "Autofill Chrome Extension" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chrome-autofi...@googlegroups.com.
To post to this group, send email to chrome-...@googlegroups.com.

Noah L

unread,
Apr 26, 2023, 7:57:04 PM4/26/23
to Autofill Extension
Hello. I see this thread is quite old, hoping someone can help me. I am using this format for my identifier for a button but no luck yet. 

document.querySelector//*@class='sc-bgqQcB ihdfDu Button__AuroraButton-sc-mbgxr4-0 kDAhbP noFocus').click()

Jojo B (Twero)

unread,
Apr 27, 2023, 12:24:40 AM4/27/23
to Autofill Extension
from a quick look, does it need open parenthesis?

takahasi hideo

unread,
Apr 27, 2023, 2:25:07 AM4/27/23
to Autofill Extension
A few days ago, I've made auto-fill extension and then connected with server.
It's really goes well.

in your case, you may use      document.getElementByClassName('sc-bgqQcB ihdfDu Button__AuroraButton-sc-mbgxr4-0 kDAhbP noFocus').click();
 or use document.querySelectorAll('.class1.class2.class3');

Good lucky!

Noah L

unread,
Apr 27, 2023, 1:25:17 PM4/27/23
to Autofill Extension
Thank you for this, Much appreciated. if anyone else comes here, I had to add SetDelay function instead of DOMcontentloaded as one of the fields had to wait for iframe to be loaded before executing. 

Elvis

unread,
Jul 30, 2023, 8:31:59 AM7/30/23
to Autofill Extension
Please someone help me to automatically click on the following button to send a form, I thank you in advance

<button _ngcontent-vyc-c74="" data-track="member-multiple-choice-continue" class="animation-submit-btn primarySection ng-star-inserted"><div _ngcontent-vyc-c74="" class="primaryTitle text submit-label"> Submit </div><div _ngcontent-vyc-c74="" class="primaryTitle text continue-label"> Continue </div><div _ngcontent-vyc-c74="" class="loadingTitle text"><suzy-spinner _ngcontent-vyc-c74="" size="small" button="true" class="absolute left-0 right-0 button-spinner top-3" _nghost-vyc-c10=""><div _ngcontent-vyc-c10=""><div _ngcontent-vyc-c10="" class="loader-wrapper"><div _ngcontent-vyc-c10="" class="loader ng-star-inserted"><svg _ngcontent-vyc-c10="" class="circular" viewBox="25 25 50 50"><circle _ngcontent-vyc-c10="" fill="none" stroke-miterlimit="10" class="path" cx="50" cy="50" r="7" stroke="#ffffff" stroke-width="2"></circle></svg></div><!----><div _ngcontent-vyc-c10="" class="text"> Finding your next question... </div></div></div></suzy-spinner></div><div _ngcontent-vyc-c74="" class="successTitle text"><svg _ngcontent-vyc-c74="" viewBox="0 0 24 24" class="animated-check"><path _ngcontent-vyc-c74="" d="M4.1 12.7L9 17.6 20.3 6.3" fill="none"></path></svg></div></button>
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages