LatticeDNA

Checking authentication...

LatticeDNA
Access Requests
No folders scanned yet
Command Center
Toolkit
Actions
Injection
Monitor
7
Properties
Articles
Live Tools
0/7
Brains
Docs Indexed
Merchants
Constellation — click a site for full profile
Priority Actions
Build Pipeline
Monitoring
Brains & Reference
Brain Loader

Drag brain files below or use the Scan All Folders button in the topbar to index your local lattice/ folder.

Drag & drop site brain files here (.txt, .html, .json)

Loaded Brains
Discovered Files
Next Best Actions — Cluster Level
Ghost-Worker Injection Manager

Manage components injected across your constellation via Cloudflare Workers + HTMLRewriter. Changes here update every page on every targeted site without redeploying.

Worker Routes

Each site needs a Worker route to enable injection. Toggle sites on/off.

Component Registry

Components are injected into every page matching their target scope. Click a component to edit.

Deploy Configuration

Export the current injection config as a JSON file. Upload this to your Cloudflare KV namespace or paste it into the Worker script. The Worker reads this config to know what to inject and where.

` }, { id: 'ai-crawler-block', name: 'AI Crawler Meta Block', position: 'append-head', target: 'all', selector: '', enabled: false, html: `\n\n\n` } ], editingId: null }; } function saveInjectionState() { localStorage.setItem(INJ_CACHE_KEY, JSON.stringify(injectionState)); } function renderInjection() { renderWorkerRoutes(); renderComponents(); } function renderWorkerRoutes() { const el = document.getElementById('injection-routes'); if (!el) return; // Sync sites from LATTICE data if new sites were added const existing = new Set(injectionState.sites.map(s => s.id)); (LATTICE.expectedSites || []).forEach(s => { if (!existing.has(s.id)) { injectionState.sites.push({ id: s.id, domain: s.domain, name: s.name, color: s.color, workerEnabled: false }); } }); el.innerHTML = `
${injectionState.sites.map(s => { const enabledComps = injectionState.components.filter(c => c.enabled && (c.target === 'all' || c.target === s.id)).length; return `
${s.name}
${s.domain}
${s.workerEnabled ? `${enabledComps} component${enabledComps !== 1 ? 's' : ''} active` : 'Worker not enabled'}
${s.workerEnabled ? `
Route: ${s.domain}/*
` : ''}
`; }).join('')}
`; } function toggleWorkerRoute(siteId, enabled) { const site = injectionState.sites.find(s => s.id === siteId); if (site) { site.workerEnabled = enabled; saveInjectionState(); renderInjection(); } } function renderComponents() { const el = document.getElementById('injection-components'); if (!el) return; const comps = injectionState.components; el.innerHTML = comps.length === 0 ? '

No components registered. Click + New Component to create one.

' : `
${comps.map(c => { const targetLabel = c.target === 'all' ? 'All Sites' : (injectionState.sites.find(s => s.id === c.target)?.name || c.target); const posLabels = { 'before-close-body': 'Before ', 'after-open-body': 'After ', 'append-head': 'Append to ', 'before-close-head': 'Before ', 'replace-selector': 'Replace: ' + (c.selector || '?') }; return `
${c.name}
${posLabels[c.position] || c.position} Target: ${targetLabel} ${c.html.length} chars
`; }).join('')}
`; } function toggleComponent(compId, enabled) { const comp = injectionState.components.find(c => c.id === compId); if (comp) { comp.enabled = enabled; saveInjectionState(); renderInjection(); } } function addComponent() { const id = 'comp-' + Date.now(); injectionState.components.push({ id, name: 'New Component', position: 'before-close-body', target: 'all', selector: '', enabled: false, html: '' }); saveInjectionState(); editComponent(id); renderComponents(); } function editComponent(compId) { const comp = injectionState.components.find(c => c.id === compId); if (!comp) return; injectionState.editingId = compId; document.getElementById('component-editor').style.display = 'block'; document.getElementById('editor-title').textContent = 'Edit: ' + comp.name; document.getElementById('comp-name').value = comp.name; document.getElementById('comp-position').value = comp.position; document.getElementById('comp-selector').value = comp.selector || ''; document.getElementById('comp-html').value = comp.html; // Populate target select const sel = document.getElementById('comp-target'); sel.innerHTML = '' + injectionState.sites.map(s => ``).join(''); sel.value = comp.target; } function closeEditor() { document.getElementById('component-editor').style.display = 'none'; injectionState.editingId = null; } function saveComponent() { const comp = injectionState.components.find(c => c.id === injectionState.editingId); if (!comp) return; comp.name = document.getElementById('comp-name').value || 'Unnamed'; comp.position = document.getElementById('comp-position').value; comp.target = document.getElementById('comp-target').value; comp.selector = document.getElementById('comp-selector').value; comp.html = document.getElementById('comp-html').value; saveInjectionState(); renderComponents(); closeEditor(); if (dbConnected) DB.saveInjectionComponent(comp); } function deleteComponent() { if (!confirm('Delete this component?')) return; const delId = injectionState.editingId; injectionState.components = injectionState.components.filter(c => c.id !== delId); saveInjectionState(); renderComponents(); closeEditor(); if (dbConnected) DB.deleteInjectionComponent(delId); } function previewComponent() { const html = document.getElementById('comp-html').value; const win = window.open('', '_blank', 'width=800,height=600'); win.document.write(`

Component Preview

${html}`); } function exportInjectionConfig() { const config = { version: '1.0', exported: new Date().toISOString(), routes: injectionState.sites.filter(s => s.workerEnabled).map(s => ({ domain: s.domain, pattern: `${s.domain}/*` })), components: injectionState.components.filter(c => c.enabled).map(c => ({ id: c.id, name: c.name, position: c.position, target: c.target, selector: c.selector || null, html: c.html })) }; const preview = document.getElementById('config-preview'); preview.style.display = 'block'; preview.textContent = JSON.stringify(config, null, 2); const blob = new Blob([JSON.stringify(config, null, 2)], { type: 'application/json' }); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `lattice-injection-config-${new Date().toISOString().split('T')[0]}.json`; a.click(); URL.revokeObjectURL(a.href); } function copyWorkerScript() { const config = { routes: injectionState.sites.filter(s => s.workerEnabled).map(s => s.domain), components: injectionState.components.filter(c => c.enabled).map(c => ({ id: c.id, position: c.position, target: c.target, selector: c.selector || null, html: c.html })) }; const script = `// =============================================================== // LatticeDNA Ghost-Worker — Injection Layer // Deploy: wrangler deploy // Generated: ${new Date().toISOString().split('T')[0]} // =============================================================== const INJECTION_CONFIG = ${JSON.stringify(config, null, 2)}; export default { async fetch(request, env) { const url = new URL(request.url); const domain = url.hostname; // Only process configured domains if (!INJECTION_CONFIG.routes.includes(domain)) { return fetch(request); } // Fetch the original static page const response = await fetch(request); const contentType = response.headers.get('content-type') || ''; if (!contentType.includes('text/html')) return response; // Build rewriter with active components for this domain let rewriter = new HTMLRewriter(); INJECTION_CONFIG.components.forEach(comp => { // Check targeting const siteId = domain.replace(/\\.com$|\\.org$|\\.net$/, ''); if (comp.target !== 'all' && comp.target !== siteId) return; if (comp.position === 'before-close-body') { rewriter = rewriter.on('body', { element(el) { el.append(comp.html, { html: true }); } }); } else if (comp.position === 'after-open-body') { rewriter = rewriter.on('body', { element(el) { el.prepend(comp.html, { html: true }); } }); } else if (comp.position === 'append-head' || comp.position === 'before-close-head') { rewriter = rewriter.on('head', { element(el) { el.append(comp.html, { html: true }); } }); } else if (comp.position === 'replace-selector' && comp.selector) { rewriter = rewriter.on(comp.selector, { element(el) { el.replace(comp.html, { html: true }); } }); } }); return rewriter.transform(response); } };`; navigator.clipboard.writeText(script).then(() => { alert('Worker script copied to clipboard. Paste into your worker.js file.'); }).catch(() => { // Fallback: show in preview const preview = document.getElementById('config-preview'); preview.style.display = 'block'; preview.textContent = script; }); } // Render injection tab when it becomes active const _origSetupTabs = setupTabs; setupTabs = function() { _origSetupTabs(); document.querySelectorAll('.tab').forEach(t => { t.addEventListener('click', () => { if (t.dataset.tab === 'injection') setTimeout(renderInjection, 50); }); }); };