📦 SITE → ONE DEOBF FILE

Paste URL → fetches, deobfuscates, packs into single HTML for Lovable

Ready.
Waiting...
`; } return match; }); // Replace each style tag with deobfuscated CSS let styleIndex = 0; const styleRegex = /]*>([\s\S]*?)<\/style>/gi; newHtml = newHtml.replace(styleRegex, (match, content) => { if (content && content.trim() && styleIndex < deobfCSS.length) { const deobf = deobfCSS[styleIndex++]; return ``; } return match; }); return { original: html, deobfuscated: newHtml, inlineJS: deobfJS, inlineCSS: deobfCSS, externalJS, externalCSS, totalJS: deobfJS.length, totalCSS: deobfCSS.length }; } // ========== UI LOGIC ========== const urlInput = document.getElementById('urlInput'); const fetchBtn = document.getElementById('fetchBtn'); const status = document.getElementById('status'); const log = document.getElementById('log'); const downloadContainer = document.getElementById('downloadContainer'); const downloadBtn = document.getElementById('downloadBtn'); let lastResult = null; fetchBtn.addEventListener('click', async () => { let url = urlInput.value.trim(); if (!url) return status.textContent = '❌ Enter a URL.'; if (!url.startsWith('http')) url = 'https://' + url; status.textContent = '⏳ Fetching...'; log.textContent = 'Loading...'; downloadContainer.classList.add('hidden'); try { const raw = await fetchSite(url); const result = deconstruct(raw, url); lastResult = result; status.textContent = `✅ Fetched ${url} | ${result.totalJS} JS blocks, ${result.totalCSS} CSS blocks, ${result.externalJS.length} external JS, ${result.externalCSS.length} external CSS`; log.textContent = `Deobfuscated HTML preview (first 2000 chars):\n\n${result.deobfuscated.slice(0, 2000)}...\n\n---\nFull file ready for download.`; downloadContainer.classList.remove('hidden'); } catch (err) { status.textContent = `❌ Error: ${err.message}`; log.textContent = `Failed: ${err.message}`; } }); downloadBtn.addEventListener('click', () => { if (!lastResult) return; const blob = new Blob([lastResult.deobfuscated], { type: 'text/html' }); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'deobfuscated-site.html'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(a.href); status.textContent = '✅ Download started – drop this file into Lovable'; }); // Auto-fetch on load window.addEventListener('load', () => fetchBtn.click());