<script language="javascript"> <script>
document.getElementById('DnsChecker').addEventListener('click', function(event) {
event.preventDefault();
Swal.fire({
title: 'Enter Domain Name',
input: 'text',
inputAttributes: {
autocapitalize: 'off'
},
showCancelButton: true,
confirmButtonText: 'Check DNS',
showLoaderOnConfirm: true,
preConfirm: (domain) => {
if (!domain) {
Swal.showValidationMessage('Please enter a domain name');
}
// Remove 'http://' or 'https://' prefix and any trailing slash (/)
domain = domain.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '').replace(/\/$/, '');
return fetch(`https://dns.google.com/resolve?name=${domain}`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
const formattedData = formatDnsRecords(data);
return formattedData;
})
.catch(error => {
Swal.showValidationMessage(`Request failed: ${error}`);
});
},
allowOutsideClick: () => !Swal.isLoading()
}).then((result) => {
if (result.isConfirmed) {
Swal.fire({
icon: 'success',
title: `DNS Records for ${result.value.domain}`,
html: result.value.html
});
}
});
});
function formatDnsRecords(data) {
let dnsHtml = '<h3>DNS:</h3><ul>';
data.Answer.forEach(answer => {
dnsHtml += `<li><strong>${answer.name}</strong>: ${answer.data}</li>`;
});
dnsHtml += '</ul>';
let moreInfoHtml = '<h3>More Info:</h3>'; // Aquí puedes poner la información adicional que desees mostrar
return { domain: data.Question[0].name, html: dnsHtml + moreInfoHtml };
}
</script></script>
© 2023 Quttera Ltd. All rights reserved.