Skip to content

Instantly share code, notes, and snippets.

@thieunguyenhung
Last active January 13, 2019 03:10
Show Gist options
  • Save thieunguyenhung/88cc0301bdd5948f80db3e69b48e17bd to your computer and use it in GitHub Desktop.
Save thieunguyenhung/88cc0301bdd5948f80db3e69b48e17bd to your computer and use it in GitHub Desktop.
How to apply multiple form in a page with Javascript in Google Chrome

How to apply multiple from with JS

First we need to analyze the page source code. Fortunately, the page call a Javascript function inside a form to apply it, so we can run a Javascript script in Google Chrome Console in Developer mode to apply all the form in this page.

The steps are:

  • Get all the forms in the page and parse them to Javascript array.
  • Filter out the form that not match your need.
  • Finally, loop through the array of forms to apply it.
var htmlForms = document.getElementsByTagName("form");
var tempForms = Array.from(htmlForms);
var forms = tempForms.filter(form => !form.getAttribute('name').includes('searchForm') && !form.getAttribute('name').includes('jre'));
forms.forEach(function (form) {
	acceptAgreement(window.self, form.getAttribute('name').replace('agreementForm',''));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment