I am manually filling out forms for a game daily, and would like to automate the process. Each form is the same except it is being sent to a different 'nation' each time, so I wanted to create a list of nations, then loop through each nation and send a form for it.
My page redirected when I tried to submit the form, so I tried to use an iframe to remain on the current page so it can send a form for every nation. I am stuck here and not sure what to do next. Is using an iframe the right way to go, or would I need to look into using an XMLHttpRequest?
It does auto-fill the input forms but it doesn't post them through to the server.
EDIT: essentially what I'm trying to do is send instructions to a website to send 'items' to a bunch of 'nations' automatically. usually this is done 1 by 1 by inputting data in a form on the website in question, then sending it one via a 'withdraw' button.
The script I am trying to build will do this automatically for an array of nations.
the site uses CSRF tokens so the script will need to get the CSRF token required and send the data with it for it to be accepted.
<HTML>
<body onload="sendForms()">
<form action="https://thewebsiteurl.com" id="autosend" target='formresponse'>
<input type="text" name="item1" value="5000">
<input type="text" name="item2" value="10">
<input type="text" name="recipient" id="nationName" value="">
</form>
<div class='iframe_container'>
<iframe name='formresponse' width='1440px' height='850px'></iframe>
</div>
</body>
<script>
var nations = ["Nation1", "Nation2","Nation3","Nation4"];
function sendForms() {
for (i = 0; i < nations.length; ++i) {
document.getElementById("nationName").setAttribute("value", nations[i]);
document.getElementById("autosend").submit();
}
}
</script>
</HTML>
I've read most of the documentation I can find relating to this issue but have a hard time interpreting it and implementing it, including trying to implement XHLHttpRequest() and xhr.send()