Skip to content

Instantly share code, notes, and snippets.

@Rawa
Last active May 2, 2024 12:32
Show Gist options
  • Save Rawa/dcc636e45f95143a8ea65ba3ca366ae8 to your computer and use it in GitHub Desktop.
Save Rawa/dcc636e45f95143a8ea65ba3ca366ae8 to your computer and use it in GitHub Desktop.
<html>
<script type="text/javascript">
let makeId = function() {
var text = "";
var possible = "abcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 10; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
let session = makeId();
var iteration = 0;
var fetchIterations = 0;
var successIterations = 0;
var failedIterations = 0;
let createUrl = function() {
let date = new Date().toISOString().replaceAll(':', '-').replace('.', '-').slice(11);
iteration++;
return "https://" + session + "-" + iteration + "-" + date + ".mullvad.test/";
}
let updateText = function() {
document.getElementById("success").textContent = "Success " + successIterations;
document.getElementById("fetch").textContent = "Fetch: " + fetchIterations;
document.getElementById("failed").textContent = "Failed: " + failedIterations;
}
let makeFetch = function() {
let url = createUrl()
fetch(url, {
mode: 'no-cors' // 'cors' by default
}).then(function(data) {
successIterations++;
updateText();
}).catch(function(err) {
failedIterations++;
updateText();
});
fetchIterations++;
updateText();
}
let start = function() {
updateText()
setInterval(makeFetch, 30)
}
</script>
<body>
<button onclick="start()">Start</button>
<h1 id="fetch"></h1>
<h1 id="success"></h1>
<h1 id="failed"></h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment