-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidator.html
61 lines (60 loc) · 1.79 KB
/
validator.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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>