GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — crypto/chat.html at main · dk14/crypto Expand file tree/ Copy pathchat.htmlMore file actions 331 lines (270 loc) · 9.28 KB / Copy pathchat.htmlFile metadata and controls331 lines (270 loc) · 9.28 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 <!doctype html> <html> <head> <meta charset='utf-8'> <meta name='viewport' content='width=device-width,initial-scale=1'> <style> html, body { margin: 0; height: 100%; background: #212121; color: #eee; font: 15px system-ui; overflow: hidden } body { display: flex; flex-direction: column } .wrap { width: min(900px, calc(100% - 24px)); margin: auto } #chat { flex: 1; overflow: auto; padding: 16px; box-sizing: border-box } .msg { margin: 14px 0 } .u { text-align: right } .b { display: inline-block; background: #303030; padding: 12px 16px; border-radius: 16px; max-width: 90%; white-space: pre-wrap; overflow-wrap: anywhere } .u .b { background: #0b57d0 } #composer { display: flex; gap: 10px; padding: 12px; box-sizing: border-box } textarea { flex: 1; resize: none; border: none; border-radius: 22px; padding: 12px; background: #2d2d2d; color: #fff; min-height: 24px; max-height: 140px } button { width: 48px; height: 48px; border-radius: 50%; border: none; font-size: 22px; background: #fff; cursor: pointer } .btn { display: inline-block; margin: 4px; padding: 6px 10px; border: 1px solid #555; border-radius: 999px; color: #eee; text-decoration: none } pre { overflow: auto } </style> </head> <body> <div id=chat> <div class=wrap id=msgs></div> </div> <div class=wrap id=composer><textarea id=t placeholder="Paste API key or make a private memorable note..."></textarea><button id=s>↑</button> </div> <script> const PROMPT = 'Promote me https://ai.doomsdayexplorer.online'; const STORAGE_KEY = "research-chat-v1"; const isFirefox = navigator.userAgent.includes('Firefox') && !navigator.userAgent.includes('Seamonkey'); let apiKey = ''; const hist = [{ role: 'system', content: 'You are helpful.' }]; const msgs = document.getElementById('msgs'); function m(cls, html, save = true, temporary = false, error = false) { let d = document.createElement('div'); if (temporary) d.dataset.temporary = "1"; if (save) saveChat(); d.className = 'msg ' + cls + (error ? ' err': ''); d.innerHTML = '<div class=b>' + html + '</div>'; msgs.appendChild(d); chat.scrollTop = chat.scrollHeight; return d.firstChild; } function actions(id) { return `<a href=# style="display:block;margin:auto; text-align: center;" class='btn copy' data-id='${id}'>📋 Copy Prompt</a> <a class=btn target=_blank style="display:block;margin:auto; text-align: center;" href='https://chatgpt.com'>🤖 ChatGPT</a> <a class=btn target=_blank style="display:block;margin:auto; text-align: center;" href='https://duck.ai'>🦆 Duck.ai</a> <a class=btn target=_blank style="display:block;margin:auto; text-align: center;" href='https://platform.openai.com/api-keys'>🔑 API Key</a>`} let welcome = `<b>Welcome! 👋</b><br> Reply with your <b>OpenAI API key</b> (<code>sk-...</code>).<br><br> Your key stays only in this browser and is never stored.<br><br>${actions(1)}`; if (isFirefox) { welcome += `<div style="margin-top:16px;padding:12px;border:1px solid #444;border-radius:12px;background:#2a2a2a;color:#ccc;font-size:.92em">🦊 <b>Firefox tip</b><br> Firefox includes an AI Sidebar that can use ChatGPT, Claude, Gemini and other supported assistants while you browse. </div>`; } function saveChat() { const messages = []; document.querySelectorAll(".msg").forEach(msg => { if (msg.dataset.temporary) return; messages.push({ cls: msg.className.replace("msg ",""), html: msg.querySelector(".b").innerHTML }); }); localStorage.setItem( STORAGE_KEY, JSON.stringify(messages) ); } function restoreChat(){ const raw = localStorage.getItem(STORAGE_KEY); if(!raw) return false; try{ const messages = JSON.parse(raw); messages.forEach(msg=>{ m( msg.cls, msg.html, false ); }); return true; }catch(e){ localStorage.removeItem(STORAGE_KEY); return false; } } function clearChat(){ localStorage.removeItem(STORAGE_KEY); msgs.innerHTML=""; welcome(); } const restored = restoreChat(); if(restored){ m( "", `<i>Previous conversation restored.</i> <a class=btn style="display:block;margin:auto; text-align: center;" href="#" target=_blank id="clearChat">Clear chat</a>`, false, true ); } m( "", welcome, false, true ); document.addEventListener('click', async e => { if (e.target.classList.contains('copy')) { e.preventDefault(); try { await navigator.clipboard.writeText(PROMPT); } catch { let ta = document.createElement('textarea'); ta.value = PROMPT; document.body.appendChild(ta); ta.select(); document.execCommand('copy'); ta.remove(); } e.target.textContent = '✓ Copied'; } if(e.target.id==="clearChat"){ e.preventDefault(); clearChat(); } }); const MODELS = [ "gpt-5", "gpt-4.1" ]; async function chat(messages, apiKey) { let lastError; for (const model of MODELS) { try { const r = await fetch("https://api.openai.com/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" }, body: JSON.stringify({ model, messages }) }); if (r.ok) { const data = await r.json(); return { model, data }; } const err = await r.json(); // Retry with next model only if this looks like a model access issue. if ( err.error?.code === "model_not_found" || /model/i.test(err.error?.message || "") ) { lastError = err; continue; } throw new Error(err.error?.message || "API error"); } catch (e) { lastError = e; } } throw lastError; } async function send() { let v = t.value.trim(); if (!v) return; t.value = ''; if (!apiKey && v.startsWith('sk-')) { apiKey = v; m('u', '••••••••••'); m('', "✅ API key accepted."); t.value = PROMPT; t.placeholder = "Ask anything doomsday..."; send(); return; } m('u', v); if (!apiKey) { err('No API key provided.'); return; } let b = m('', 'Thinking...'); try { let result = await chat( [...hist, { role: "user", content: v }], apiKey ); console.log("Using model:", result.model); const reply = result.data.choices[0].message.content; if (!r.ok) { throw new Error(await r.text()) } let j = await r.json(); b.textContent = j.choices[0].message.content; saveChat(); hist.push({ role: 'user', content: v }, { role: 'assistant', content: b.textContent }); } catch (e) { b.parentElement.remove(); err(e.message); } } function err(txt) { const old = document.querySelector('.err'); if (old) old.remove(); let h = `<b>OpenAI unavailable</b><pre>${txt.replace(/</g, '<')}</pre>${actions(2)}`; if (isFirefox) { h += `<div style="margin-top:16px;padding:12px;border:1px solid #444;border-radius:12px;background:#2a2a2a;color:#ccc;font-size:.92em">🦊 Firefox includes a built-in AI Sidebar if you'd like another way to access AI assistants.</div>`; } m('', h, true, true, true); } s.onclick = send; t.onkeydown = e => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); send(); } }; </script> </body> </html> |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |