CF Browser — Powered by Cloudflare Pages
100%
Not connected
Room Chat✕
Ready
`; let processedHtml = html; // Inject base tag const base = new URL(url).origin + new URL(url).pathname.replace(/[^/]*$/, ''); processedHtml = processedHtml.replace(/]*)>/i, ''); // Inject proxy script if (processedHtml.includes('')) { processedHtml = processedHtml.replace('', proxyScript + ''); } else { processedHtml = proxyScript + processedHtml; } const iframe = document.createElement('iframe'); iframe.className = 'webview'; iframe.srcdoc = processedHtml; iframe.onload = () => { tab.loading = false; try { const t = iframe.contentDocument?.title; if (t && t !== activeTab?.title) { tab.title = t; renderTabs(); } } catch {} document.getElementById('statusbar').textContent = 'Done'; }; const content = document.getElementById('content'); content.innerHTML = ''; content.appendChild(iframe); // Listen for title messages // (handled by global listener below) } catch (err) { tab.loading = false; showError(url, err.message); renderTabs(); } }; // Listen for title messages from iframe window.addEventListener('message', (e) => { if (e.data && e.data.type === 'title' && activeTab) { if (e.data.title) { activeTab.title = e.data.title; renderTabs(); } } }); // ===== COOKIE MANAGER UI ===== function openCookieManager() { const overlay = document.createElement('div'); overlay.className = 'settings-overlay'; let html = '

🍪 Cookies

'; const domains = Object.keys(cookies); if (domains.length === 0) { html += '

No cookies stored.

'; } else { domains.forEach(domain => { html += '
'; cookies[domain].forEach((c, i) => { html += '
' + c.name + '=' + c.value.slice(0,30) + '
'; }); html += '
'; }); } html += ''; html += ''; html += '
'; overlay.innerHTML = html; overlay.addEventListener('click', (e) => { if (e.target === overlay) overlay.remove(); }); document.body.appendChild(overlay); } function deleteCookie(domain, idx) { if (cookies[domain]) { cookies[domain].splice(idx, 1); if (cookies[domain].length === 0) delete cookies[domain]; saveCookies(); } // Re-render const overlay = document.querySelector('.settings-overlay'); if (overlay) { overlay.remove(); openCookieManager(); } } // Add cookie manager button to settings (patch openSettings) const _origOpenSettings = openSettings; openSettings = function() { _origOpenSettings(); // Add cookie manager link const panel = document.querySelector('.settings-panel'); if (panel) { const link = document.createElement('button'); link.className = 'settings-close'; link.style.background = '#3a3a5e'; link.style.marginTop = '8px'; link.textContent = '🍪 Manage Cookies'; link.onclick = () => { panel.closest('.settings-overlay').remove(); openCookieManager(); }; panel.appendChild(link); } };