Created
April 3, 2013 19:34
-
-
Save mondalaci/5304529 to your computer and use it in GitHub Desktop.
Greasemonkey snippet for automating HTTP requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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