Skip to content

Instantly share code, notes, and snippets.

@mondalaci
Created April 3, 2013 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mondalaci/5304529 to your computer and use it in GitHub Desktop.
Save mondalaci/5304529 to your computer and use it in GitHub Desktop.
Greasemonkey snippet for automating HTTP requests
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment