document.addEventListener('DOMContentLoaded', function() { const domainInput = document.getElementById('domainInput'); const scanBtn = document.getElementById('scanBtn'); const resultsSection = document.getElementById('resultsSection'); const scanResults = document.getElementById('scanResults'); // Mock API function - in a real implementation, this would call actual threat intelligence APIs async function scanDomain(domain) { return new Promise((resolve) => { setTimeout(() => { // Simulate API response const isSuspicious = Math.random() > 0.7; // 30% chance to be flagged const response = { domain, isSuspicious, lastScanned: new Date().toISOString(), reputationScore: Math.floor(Math.random() * 100), categories: isSuspicious ? ['Adult Content', 'Potential CSAM', 'High Risk'] : ['General Content', 'Low Risk'], hostingInfo: { ip: `192.168.${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}`, country: isSuspicious ? 'Offshore Location' : 'United States', registrar: isSuspicious ? 'Anonymous Registrar Inc' : 'GoDaddy LLC' }, threatIndicators: isSuspicious ? ['Known bad IP neighborhood', 'Recently registered domain', 'Hidden WHOIS'] : ['Clean record'], historicalData: { firstSeen: new Date(Date.now() - Math.floor(Math.random() * 31536000000)).toISOString().split('T')[0], changes: Math.floor(Math.random() * 10) } }; resolve(response); }, 1500); // Simulate network delay }); } function displayResults(data) { scanResults.innerHTML = ''; const resultCard = document.createElement('div'); resultCard.className = 'bg-gray-700 rounded-lg p-6'; const statusColor = data.isSuspicious ? 'text-red-500' : 'text-green-500'; const statusText = data.isSuspicious ? 'SUSPICIOUS' : 'CLEAN'; resultCard.innerHTML = `

${data.domain}

Scanned: ${new Date(data.lastScanned).toLocaleString()}

${statusText}

Reputation Score

${data.reputationScore}/100

Content Categories

${data.categories.map(cat => ` ${cat} `).join('')}

Hosting Information

IP: ${data.hostingInfo.ip}

Country: ${data.hostingInfo.country}

Registrar: ${data.hostingInfo.registrar}

Threat Indicators

${data.isSuspicious ? `

Warning

This domain has been flagged for potentially harmful content. Consider reporting to appropriate authorities.

` : ''} `; scanResults.appendChild(resultCard); feather.replace(); } scanBtn.addEventListener('click', async function() { const domain = domainInput.value.trim(); if (!domain) { alert('Please enter a domain to scan'); return; } // Simple domain validation if (!/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(domain)) { alert('Please enter a valid domain name'); return; } // Show loading state scanBtn.disabled = true; scanBtn.innerHTML = ` Scanning...`; feather.replace(); try { const results = await scanDomain(domain); displayResults(results); resultsSection.classList.remove('hidden'); } catch (error) { alert('Error scanning domain: ' + error.message); } finally { scanBtn.disabled = false; scanBtn.innerHTML = ` Scan Domain`; feather.replace(); } }); // Allow Enter key to trigger scan domainInput.addEventListener('keypress', function(e) { if (e.key === 'Enter') { scanBtn.click(); } }); });