Skip to content

Commit

Permalink
Create validator.html
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkingfeeling authored Apr 5, 2023
1 parent 61c8f2d commit 7ffd4d7
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions validator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Domain Name Validator</title>
<script>
function checkDomains() {
const inputElement = document.getElementById('inputBox');
const outputElement = document.getElementById('outputBox');
const domains = inputElement.value.split('\n');
const validDomains = [];
const apiUrl = 'https://cloudflare-dns.com/dns-query';
const dnsParams = {
type: 'A',
cd: true,
};
for (let domain of domains) {
domain = domain.trim();
fetch(`${apiUrl}?name=${domain}`, {
method: 'GET',
headers: {
'Accept': 'application/dns-json',
},
})
.then(response => response.json())
.then(data => {
if (data.Status === 0 && data.Answer && data.Answer.length > 0 && data.Answer[0].type === 1) {
validDomains.push(domain);
}
})
.catch(error => {
console.error(`Error checking domain ${domain}: ${error}`);
});
}
Promise.allSettled(domains.map(domain => {
return fetch(`${apiUrl}?name=${domain}`, {
method: 'GET',
headers: {
'Accept': 'application/dns-json',
},
})
.then(response => response.json())
}))
.then(results => {
outputElement.value = validDomains.join('\n');
});
}
</script>
</head>
<body>
<h1>Domain Name Validator</h1>
<form>
<label for="inputBox">Enter domain names, one per line:</label><br>
<textarea id="inputBox" name="inputBox" rows="10" cols="50"></textarea><br>
<input type="button" value="Validate Domains" onclick="checkDomains()">
</form>
<h2>Valid Domains:</h2>
<textarea id="outputBox" rows="10" cols="50"></textarea>
</body>
</html>

0 comments on commit 7ffd4d7

Please sign in to comment.