Skip to content

Instantly share code, notes, and snippets.

@svenhakvoort
Created April 24, 2018 09:58
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 svenhakvoort/a5e1b5586176cc88e4f259c09ddc3026 to your computer and use it in GitHub Desktop.
Save svenhakvoort/a5e1b5586176cc88e4f259c09ddc3026 to your computer and use it in GitHub Desktop.
ELKKPB
<form method="POST" id="form">
<input type="text" name="email"/><br/>
<input type="password" name="password"/><br/>
<button type="submit">Submit</button>
</form>
$("#form").on("submit", function(e) {
e.preventDefault();
var vars = $(this).serializeArray();
var email = vars[0].value;
var password = vars[1].value;
getRoutes(email, password);
});
function getRoutes(email, password) {
var settings = {
"async": true,
"crossDomain": true,
"url": "https://my-first-playground-ou5au0oobs39.runkit.sh/test",
"method": "POST",
"headers": {
"content-type": "application/x-www-form-urlencoded",
"cache-control": "no-cache"
},
"data": {
"email": email,
"password": password
}
}
$.ajax(settings).done(function (response) {
var urls = response.split("\n");
openUrl(urls, 0, 0)
});
}
function openUrl(urls, i, count) {
if (i < urls.length) {
var win = window.open(urls[i], '_blank');
console.log(count);
if (count >= 10) {
console.log("SLEEP")
count = 0
setTimeout(function() { openUrl(urls, i+1, count)}, 60000);
} else {
openUrl(urls, i+1, count+1);
}
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment