So I made this IP script were when you get on my website it shows you your IP.
What I want to do is make a simple IP blocker, I want it to find the value of the header that contains the IP address as text, and make it so that if IPHEADER.text or something == "GOODIP" alert("RIGHT IP!"); else window.location = "SOMETHING"
... I know that was bad JavaScript, but it was just an example.
Here is the current code I have.
<h3 id="testIp"></h3>
<script>
function text(url) {
return fetch(url).then(res => res.text());
}
text('https://www.cloudflare.com/cdn-cgi/trace').then(data => {
let ipRegex = /[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/
let ip = data.match(ipRegex)[0];
document.getElementById('testIp').innerHTML = (ip);
});
-->NEED HELP PAST HERE<---
function validate() {
if (document.getElementById("testIp").innerHTML == "The Right IP") {
alert("RIGHT IP!");
} else {
alert('WRONG IP!');
}
}
</script>
Thanks!