@ywkrlerche/richardwho 1.0.44 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app.js CHANGED
@@ -454,7 +454,7 @@
454
454
  // The pointer pushes them aside; clicking empty space bursts out more (and sets off a firework when there are any).
455
455
  const fallers = {
456
456
  canvas: null, ctx: null, list: [], kind: null, items: [], sprites: {}, target: 0, raf: 0, last: 0, measured: 0,
457
- w: 0, h: 0, ox: 0, oy: 0, px: -1e4, py: -1e4, dir: 1, fw: null, fwRate: 0, sparks: [],
457
+ w: 0, h: 0, ox: 0, oy: 0, px: -1e4, py: -1e4, dir: 1, fw: null, fwRate: 0, sparks: [], cost: 0, skip: false,
458
458
  still: matchMedia("(prefers-reduced-motion: reduce)").matches,
459
459
  set(theme) {
460
460
  const fall = theme === "halloween" ? SPOOKY_FALL : FESTS[theme];
@@ -490,7 +490,7 @@
490
490
  });
491
491
  },
492
492
  resize() {
493
- const r = this.canvas.getBoundingClientRect(), d = Math.min(devicePixelRatio || 1, 2);
493
+ const r = this.canvas.getBoundingClientRect(), d = Math.min(devicePixelRatio || 1, 1.5); // sharper than this isn't worth the extra drawing
494
494
  this.ox = r.left; this.oy = r.top;
495
495
  if (r.width === this.w && r.height === this.h) return;
496
496
  this.w = r.width; this.h = r.height;
@@ -546,10 +546,13 @@
546
546
  this.raf = 0;
547
547
  if (!this.kind || document.hidden) return;
548
548
  if ($("view-home").hidden) { setTimeout(() => this.start(), 500); return; }
549
+ // a slow computer (drawing takes over 5ms) gets 30 frames a second instead of 60; movement keeps the same speed
550
+ if (this.cost > 5 && (this.skip = !this.skip)) { this.raf = requestAnimationFrame((t2) => this.frame(t2)); return; }
551
+ const began = performance.now();
549
552
  const dt = Math.min(3, (t - this.last) / 16.7);
550
553
  this.last = t;
551
554
  if (t - this.measured > 1000) { this.measured = t; this.resize(); } // the side bar can slide in or out
552
- const ctx = this.ctx, snow = this.kind === "snow", R = 110, damp = Math.pow(.95, dt);
555
+ const ctx = this.ctx, snow = this.kind === "snow", R = 110, damp = Math.pow(.95, dt), px = this.canvas.width / this.w;
553
556
  ctx.clearRect(0, 0, this.w, this.h);
554
557
  if (this.fw && !this.still && Math.random() < this.fwRate * dt / 60) this.firework(this.w * (.1 + Math.random() * .8), this.h * (.12 + Math.random() * .36));
555
558
  if (this.sparks.length) {
@@ -578,10 +581,11 @@
578
581
  Object.assign(p, this.make(false));
579
582
  }
580
583
  if (snow) { ctx.moveTo(p.x + p.size, p.y); ctx.arc(p.x, p.y, p.size, 0, 6.283); }
581
- else { ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.scale(this.canvas.width / this.w, this.canvas.height / this.h); ctx.translate(p.x, p.y); ctx.rotate(p.rot); ctx.drawImage(this.sprite(p.item), -p.size / 2, -p.size / 2, p.size, p.size); }
584
+ else { const c = Math.cos(p.rot) * px, s = Math.sin(p.rot) * px; ctx.setTransform(c, s, -s, c, p.x * px, p.y * px); ctx.drawImage(this.sprite(p.item), -p.size / 2, -p.size / 2, p.size, p.size); }
582
585
  }
583
586
  if (snow) ctx.fill();
584
- else { const d = this.canvas.width / this.w; ctx.setTransform(d, 0, 0, d, 0, 0); ctx.globalAlpha = 1; }
587
+ else { ctx.setTransform(px, 0, 0, px, 0, 0); ctx.globalAlpha = 1; }
588
+ this.cost = this.cost * .9 + (performance.now() - began) * .1;
585
589
  if (!this.still) this.raf = requestAnimationFrame((t2) => this.frame(t2));
586
590
  },
587
591
  };
@@ -856,11 +860,11 @@
856
860
  }
857
861
 
858
862
  // ---------- Routing: "" home, #games, #recent, #play/<id> ----------
859
- const VIEW_ORDER = ["home", "games", "trivia", "ai", "chat", "stats", "settings", "changelog"];
863
+ const VIEW_ORDER = ["home", "games", "trivia", "chat", "stats", "settings", "changelog"];
860
864
  let lastView = null;
861
865
  function viewFor(hash) {
862
866
  return hash === "#games" || hash === "#recent" ? "games" : hash === "#settings" ? "settings" : hash === "#chat" ? "chat"
863
- : hash === "#stats" ? "stats" : hash === "#changelog" ? "changelog" : hash === "#ai" ? "ai" : hash === "#trivia" ? "trivia" : "home";
867
+ : hash === "#stats" ? "stats" : hash === "#changelog" ? "changelog" : hash === "#trivia" ? "trivia" : "home";
864
868
  }
865
869
  // Switching pages: the old page slides out while the new one slides in (down the side bar = upward,
866
870
  // up the side bar = downward). Uses the browser's view transitions; older browsers just switch.
@@ -899,9 +903,9 @@
899
903
  $("view-settings").hidden = view !== "settings";
900
904
  $("view-chat").hidden = view !== "chat";
901
905
  lastView = view;
906
+ document.body.dataset.view = view; // page-specific styles key off this (cheaper than :has())
902
907
  $("view-stats").hidden = view !== "stats";
903
908
  $("view-changelog").hidden = view !== "changelog";
904
- $("view-ai").hidden = view !== "ai";
905
909
  $("view-trivia").hidden = view !== "trivia";
906
910
  if (view !== "trivia") { // leaving: stop the clock, close any puzzle site, and a half-done quiz starts over next time
907
911
  stopTriviaTimer();
@@ -911,7 +915,6 @@
911
915
  $("trivia-daily").hidden = false;
912
916
  renderDaily();
913
917
  }
914
- if (view === "ai") { renderAi(); setTimeout(() => $("ai-input").focus(), 50); }
915
918
  if (view === "changelog") renderChangelog();
916
919
  placeChatBox();
917
920
  if (view === "settings") { renderSettings(); renderAdmin(); }
@@ -983,8 +986,10 @@
983
986
  // Newest first. Add an entry here with every publish; its version should match package.json.
984
987
  // Each has: new (features), games (added/removed/fixed games), fixes (bugs). Leave a list out if empty.
985
988
  const CHANGELOG = [
989
+ { version: "1.0.45", date: "2026-11-13",
990
+ new: ["New game: 60 Seconds! Reatomized"], fixes: ["The whole site is faster and smoother, especially on Chromebooks: less work in the background on every page, and much smoother scrolling on the Games page", "The Google Classroom loading screen was removed", "The AI chat was removed"] },
986
991
  { version: "1.0.44", date: "2026-11-12",
987
- new: ["🔒 Private chat rooms: host a room, share its 6-character code, and chat with just the people who have it. Each room gets its own tab next to Public, with a dot when someone posts (rooms last 24 hours)", "🎨 Every holiday theme now has its own drawn scene, with fireworks on New Year's and the Fourth of July and a countdown to the big day", "🎉 New themes: Super Bowl weekend, April Fools' Day, summer break and back to school", "Holiday colors now show on every page, not just the home page", "💰 A Tycoon section on the Games page: Monkey Mart, Adventure Capitalist, Hardware Tycoon, OpenTTD and more", "The site now looks like Google Classroom loading for a moment before the loading screen (it follows the tab disguise setting)"],
992
+ new: ["🔒 Private chat rooms: host a room, share its 6-character code, and chat with just the people who have it. Each room gets its own tab next to Public, with a dot when someone posts (rooms last 24 hours)", "🎨 Every holiday theme now has its own drawn scene, with fireworks on New Year's and the Fourth of July and a countdown to the big day", "🎉 New themes: Super Bowl weekend, April Fools' Day, summer break and back to school", "Holiday colors now show on every page, not just the home page", "💰 A Tycoon section on the Games page: Monkey Mart, Adventure Capitalist, Hardware Tycoon, OpenTTD and more"],
988
993
  fixes: ["In the .svg version, Back from a game no longer lands on a list of files"] },
989
994
  { version: "1.0.43", date: "2026-11-10",
990
995
  new: [], fixes: ["The .svg version now shows your tab disguise (like Google Classroom) in the browser tab", "In the .svg version, the link back to the normal site is at the bottom of the Games page and opens its Games page"] },
@@ -3383,7 +3388,6 @@
3383
3388
  [".rail-btn[data-nav=games]", "Games", "Every game, by category. There's a Game of the day and the most played games at the top."],
3384
3389
  [".rail-btn[data-nav=trivia]", "Trivia", "Quick quizzes, NFL, NBA and MLB team trivia, and a daily challenge with a leaderboard."],
3385
3390
  ["#soundboard-btn", "Soundboard", "Meme sounds and effects, one click away."],
3386
- [".rail-btn[data-nav=ai]", "AI chat", "Ask anything: homework help, game ideas, or just questions."],
3387
3391
  [".rail-btn[data-nav=chat]", "Chat", "Talk with everyone on the site. Be nice, and you can post polls too."],
3388
3392
  ["#panic-btn", "Panic button", "Jumps straight to Google Classroom. The ` and ] keys do it too."],
3389
3393
  [".rail-btn[data-nav=settings]", "Settings", "Themes, the tab disguise, the panic page and more. You can replay this tour there."],
@@ -3406,6 +3410,7 @@
3406
3410
  const r = target && target.offsetParent !== null ? target.getBoundingClientRect() : null;
3407
3411
  const spot = $("tour-spot"), card = $("tour-card");
3408
3412
  spot.hidden = !r;
3413
+ $("tour").classList.toggle("spot-on", !!r);
3409
3414
  if (r) Object.assign(spot.style, { left: `${r.left - 6}px`, top: `${r.top - 6}px`, width: `${r.width + 12}px`, height: `${r.height + 12}px` });
3410
3415
  $("tour-step").textContent = `${tour.i + 1} of ${TOUR_STEPS.length}`;
3411
3416
  $("tour-title").textContent = title;
@@ -3432,255 +3437,6 @@
3432
3437
  addEventListener("resize", () => { if (!$("tour").hidden) tourStep(); });
3433
3438
  }
3434
3439
 
3435
- // ---------- AI chat ----------
3436
- // One chatbot backed by several free AI services. It tries them in order (Gemini, Groq, OpenRouter,
3437
- // Mistral); when one is out of free messages, down or missing a key, it moves to the next.
3438
- // Keys go in config.js (ai: { gemini, groq, openrouter, mistral }). Models are picked from each service's
3439
- // own current list, so renamed models don't break it. The conversation is kept in this browser only.
3440
- const AI_KEY = "rug-ai-chat";
3441
- const AI_SYSTEM = "You are the helpful AI on richardwho, a games site used by students. Be friendly, clear and fairly short. " +
3442
- "Help with homework by explaining how to solve things, not just giving answers. Keep everything appropriate for school: " +
3443
- "no sexual content, no graphic violence, nothing hateful, nothing dangerous or illegal. Use Markdown for lists and code. " +
3444
- "Never use LaTeX; write math in plain text (like CO2, x^2, 6CO2 + 6H2O -> C6H12O6 + 6O2).";
3445
- const ai = { busy: false, models: {}, chats: [], currentId: null, pendingImg: null };
3446
- const aiKeys = () => CFG.ai || {};
3447
- const AI_SERVICES = [
3448
- { id: "gemini", name: "Gemini",
3449
- async pickModel(key) {
3450
- const r = await fetch("https://generativelanguage.googleapis.com/v1beta/models?pageSize=200", { headers: { "x-goog-api-key": key } });
3451
- const list = (await r.json()).models || [];
3452
- const ok = list.filter((m) => (m.supportedGenerationMethods || []).includes("generateContent") && /gemini/.test(m.name) && !/(image|tts|audio|embedding|live|preview-tts|robotics)/.test(m.name));
3453
- // newest first, full flash before lite; the newest often has no free messages, so ask() walks down the list
3454
- const rank = (m) => (/flash/.test(m.name) ? 0 : 2) + (/lite/.test(m.name) ? 1 : 0);
3455
- const names = ok.filter((m) => !/preview|latest|omni/.test(m.name))
3456
- .sort((a, b) => rank(a) - rank(b) || b.name.localeCompare(a.name, undefined, { numeric: true })).map((m) => m.name);
3457
- // the model that worked last time goes first, so only the very first visit has to search
3458
- let good = null;
3459
- try { good = localStorage.getItem("rug-ai-gemini"); } catch {}
3460
- // the model set in config.js first, then the one that worked last time, then the rest
3461
- for (const want of [good, aiKeys().geminiModel && "models/" + aiKeys().geminiModel]) {
3462
- if (want && names.includes(want)) names.unshift(...names.splice(names.indexOf(want), 1));
3463
- }
3464
- return names.length ? names : null;
3465
- },
3466
- async ask(key, models, msgs) {
3467
- let good = null;
3468
- try { good = localStorage.getItem("rug-ai-gemini"); } catch {}
3469
- for (const model of [...models]) {
3470
- // an untested model gets 8s (overloaded ones just hang); a known-good one gets time for long answers
3471
- const r = await fetch(`https://generativelanguage.googleapis.com/v1beta/${model}:generateContent`, {
3472
- method: "POST", headers: { "Content-Type": "application/json", "x-goog-api-key": key }, signal: AbortSignal.timeout(model === good ? 45000 : 8000),
3473
- body: JSON.stringify({ systemInstruction: { parts: [{ text: AI_SYSTEM }] },
3474
- contents: msgs.map((m) => ({ role: m.role === "assistant" ? "model" : "user", parts: [{ text: m.text },
3475
- ...(m.img ? [{ inline_data: { mime_type: m.img.slice(5, m.img.indexOf(";")), data: m.img.slice(m.img.indexOf(",") + 1) } }] : [])] })) }),
3476
- }).catch(() => ({ ok: false, status: "timeout" }));
3477
- if (!r.ok) { models.splice(models.indexOf(model), 1); continue; } // out of free messages for this model: next one
3478
- try { localStorage.setItem("rug-ai-gemini", model); } catch {}
3479
- const d = await r.json();
3480
- return (d.candidates?.[0]?.content?.parts || []).map((p) => p.text || "").join("").trim();
3481
- }
3482
- throw new Error("gemini: no model with free messages left");
3483
- } },
3484
- { id: "groq", name: "Groq", base: "https://api.groq.com/openai/v1",
3485
- prefer: [/llama.*70b/, /llama/, /qwen/, /gpt-oss/], avoid: /(whisper|guard|tts|vision|embed)/ },
3486
- { id: "openrouter", name: "OpenRouter", base: "https://openrouter.ai/api/v1",
3487
- prefer: [/llama/, /gemma/, /qwen/, /mistral/, /nemotron.*super/, /./], avoid: /(content-safety|code|coder|guard|vision|vl|embed)/, freeOnly: true },
3488
- { id: "mistral", name: "Mistral", base: "https://api.mistral.ai/v1",
3489
- prefer: [/mistral-small-latest/, /mistral-medium-latest/, /mistral-large-latest/, /mistral/], avoid: /(embed|ocr|moderation|codestral|pixtral)/ },
3490
- ];
3491
- // Groq, OpenRouter and Mistral all speak the same (OpenAI-style) format
3492
- const openAiStyle = {
3493
- async pickModel(key, svc) {
3494
- const r = await fetch(`${svc.base}/models`, { headers: { Authorization: `Bearer ${key}` } });
3495
- let ids = ((await r.json()).data || []).map((m) => m.id).filter((id) => !svc.avoid.test(id));
3496
- if (svc.freeOnly) ids = ids.filter((id) => id.endsWith(":free"));
3497
- for (const re of svc.prefer) { const hit = ids.find((id) => re.test(id)); if (hit) return hit; }
3498
- return ids[0];
3499
- },
3500
- async ask(key, model, msgs, svc) {
3501
- const r = await fetch(`${svc.base}/chat/completions`, {
3502
- method: "POST",
3503
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}`, ...(svc.id === "openrouter" ? { "X-Title": "richardwho" } : {}) },
3504
- body: JSON.stringify({ model, messages: [{ role: "system", content: AI_SYSTEM }, ...msgs.map((m) => ({ role: m.role, content: m.img ? m.text + "\n\n(The user attached a picture, but you can't see pictures. Say so if it matters.)" : m.text }))], max_tokens: 1200 }),
3505
- });
3506
- if (!r.ok) throw new Error(`${svc.id} ${r.status}`);
3507
- const d = await r.json();
3508
- return (d.choices?.[0]?.message?.content || "").trim();
3509
- },
3510
- };
3511
- function aiReady() { return AI_SERVICES.some((s) => aiKeys()[s.id]); }
3512
- async function askAi(msgs) {
3513
- const order = msgs.some((m) => m.img) ? [...AI_SERVICES].sort((x) => (x.id === "gemini" ? -1 : 0)) : AI_SERVICES;
3514
- for (const svc of order) {
3515
- const key = aiKeys()[svc.id];
3516
- if (!key) continue;
3517
- const impl = svc.ask ? svc : openAiStyle;
3518
- try {
3519
- ai.models[svc.id] ||= (aiKeys().models || {})[svc.id] || await impl.pickModel(key, svc);
3520
- if (!ai.models[svc.id]) throw new Error("no model");
3521
- const text = await impl.ask(key, ai.models[svc.id], msgs, svc);
3522
- if (text) return { text, by: svc.name };
3523
- } catch (err) {
3524
- console.warn("AI service skipped:", svc.name, err.message); // out of free messages, down, or bad key: try the next
3525
- }
3526
- }
3527
- throw new Error("all busy");
3528
- }
3529
- // Light Markdown: code blocks, inline code, bold, italics, lists, links (everything escaped first)
3530
- function aiFormat(text) {
3531
- const blocks = [];
3532
- let h = escapeHtml(text).replace(/```[a-z0-9+-]*\n?([\s\S]*?)```/gi, (m, code) => { blocks.push(code.replace(/\n$/, "")); return `\u0000${blocks.length - 1}\u0000`; });
3533
- h = h.replace(/`([^`\n]+)`/g, "<code>$1</code>")
3534
- .replace(/\*\*([^*\n]+)\*\*/g, "<strong>$1</strong>")
3535
- .replace(/(^|[\s(])\*([^*\n]+)\*(?=[\s).,!?:;]|$)/g, "$1<em>$2</em>")
3536
- .replace(/\[([^\]\n]+)\]\((https?:\/\/[^)\s]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
3537
- // line by line; runs of "- item" become a bullet list, runs of "1. item" a numbered list
3538
- const out = [];
3539
- let list = null;
3540
- for (const line of h.split("\n")) {
3541
- const bullet = line.match(/^\s*[-*•] (.*)/), num = line.match(/^\s*\d+[.)] (.*)/);
3542
- const kind = bullet ? "ul" : num ? "ol" : null;
3543
- if (list && list !== kind) { out.push(`</${list}>`); list = null; }
3544
- if (kind) { if (!list) { out.push(`<${kind}>`); list = kind; } out.push(`<li>${(bullet || num)[1]}</li>`); continue; }
3545
- if (/^\s*([-*_])\1{2,}\s*$/.test(line)) out.push("<hr>");
3546
- else if (/^#{1,6} /.test(line)) out.push(`<p class="ai-h">${line.replace(/^#+ /, "")}</p>`);
3547
- else if (line.trim()) out.push(`<p>${line}</p>`);
3548
- }
3549
- if (list) out.push(`</${list}>`);
3550
- return out.join("").replace(/\u0000(\d+)\u0000/g, (m, i) => `<pre><code>${blocks[i]}</code></pre>`);
3551
- }
3552
- // -- AI page: several saved chats (this browser only), search, suggestions, pictures, daily usage --
3553
- const AI_CHATS_KEY = "rug-ai-chats", AI_USAGE_KEY = "rug-ai-usage", AI_DAILY = 100;
3554
- const AI_SUGGESTIONS = [
3555
- ["🍝", "What should I make for dinner?"], ["😂", "Tell me a joke"],
3556
- ["🎬", "Recommend a movie to watch"], ["💡", "Give me a fun fact"],
3557
- ];
3558
- function aiLoadChats() {
3559
- const old = store.get(AI_KEY, null); // the first version kept one chat; bring it over
3560
- let chats = store.get(AI_CHATS_KEY, []);
3561
- if (Array.isArray(old) && old.length && !chats.length) chats = [{ id: Date.now().toString(36), title: aiTitle(old[0].text), ts: Date.now(), messages: old }];
3562
- store.set(AI_KEY, null);
3563
- return Array.isArray(chats) ? chats : [];
3564
- }
3565
- function aiTitle(text) { const t = String(text || "").replace(/\s+/g, " ").trim(); return t.length > 40 ? t.slice(0, 40) + "…" : t || "New chat"; }
3566
- function aiSave() {
3567
- // pictures are kept for this visit only (they'd fill the browser's storage)
3568
- const slim = ai.chats.slice(0, 50).map((c) => ({ ...c, messages: c.messages.slice(-60).map(({ img, ...m }) => (img ? { ...m, hadImg: true } : m)) }));
3569
- store.set(AI_CHATS_KEY, slim);
3570
- }
3571
- const aiCurrent = () => ai.chats.find((c) => c.id === ai.currentId) || null;
3572
- // Usage: AI_DAILY messages a day on this device, starting fresh at midnight
3573
- function aiUsage() {
3574
- const today = new Date().toDateString(), u = store.get(AI_USAGE_KEY, {});
3575
- return u.day === today ? u : { day: today, used: 0 };
3576
- }
3577
- function renderAiUsage() {
3578
- const u = aiUsage(), left = Math.max(0, AI_DAILY - u.used);
3579
- $("ai-usage-used").textContent = `${u.used}/${AI_DAILY}`;
3580
- $("ai-usage-left").textContent = `${left} left`;
3581
- $("ai-usage-fill").style.width = `${Math.min(100, (u.used / AI_DAILY) * 100)}%`;
3582
- $("ai-foot").textContent = `${u.used}/${AI_DAILY} today · ${left} remaining · resets at midnight`;
3583
- }
3584
- function aiGroup(ts) {
3585
- const d = new Date(ts), now = new Date(), day = 86400000;
3586
- const start = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
3587
- return ts >= start ? "Today" : ts >= start - day ? "Yesterday" : ts >= start - 7 * day ? "Last 7 days" : "Older";
3588
- }
3589
- function renderAiChats() {
3590
- const q = $("ai-search").value.trim().toLowerCase();
3591
- const list = ai.chats.filter((c) => !q || c.title.toLowerCase().includes(q) || c.messages.some((m) => m.text.toLowerCase().includes(q)));
3592
- let html = "", last = "";
3593
- for (const c of list) {
3594
- const g = aiGroup(c.ts);
3595
- if (g !== last) { html += `<p class="ai-group">${g}</p>`; last = g; }
3596
- html += `<button class="ai-chat-item${c.id === ai.currentId ? " on" : ""}" type="button" data-chat="${escapeHtml(c.id)}">💬 <span>${escapeHtml(c.title)}</span></button>`;
3597
- }
3598
- $("ai-chats").innerHTML = html || `<p class="ai-group">${q ? "No chats match." : "No chats yet."}</p>`;
3599
- }
3600
- function renderAi() {
3601
- const ready = aiReady(), c = aiCurrent(), msgs = c?.messages || [];
3602
- $("ai-off").hidden = ready;
3603
- $("ai-form").hidden = !ready;
3604
- $("ai-title").textContent = c ? c.title : "New chat";
3605
- $("ai-delete").hidden = !c;
3606
- const log = $("ai-log");
3607
- if (!msgs.length) {
3608
- log.innerHTML = ready ? `<div class="ai-welcome"><h2>What can I help you with today?</h2><div class="ai-suggest">` +
3609
- AI_SUGGESTIONS.map(([icon, text]) => `<button type="button" data-suggest="${escapeHtml(text)}"><span aria-hidden="true">${icon}</span>${escapeHtml(text)}</button>`).join("") + `</div></div>` : "";
3610
- } else {
3611
- log.innerHTML = msgs.map((m) => m.role === "assistant"
3612
- ? `<div class="ai-msg assistant">${aiFormat(m.text)}${m.by ? `<span class="ai-by">${escapeHtml(m.by)}</span>` : ""}</div>`
3613
- : `<div class="ai-msg user">${m.img ? `<img class="ai-msg-img" src="${m.img}" alt="Picture you sent">` : m.hadImg ? `<p class="ai-img-note">📷 picture</p>` : ""}<p>${escapeHtml(m.text)}</p></div>`).join("");
3614
- if (ai.busy) log.insertAdjacentHTML("beforeend", `<div class="ai-msg assistant thinking"><span></span><span></span><span></span></div>`);
3615
- }
3616
- log.scrollTop = log.scrollHeight;
3617
- renderAiChats();
3618
- renderAiUsage();
3619
- }
3620
- async function sendAi(e, preset) {
3621
- e?.preventDefault();
3622
- const box = $("ai-input"), text = (preset ?? box.value).trim();
3623
- if ((!text && !ai.pendingImg) || ai.busy) return;
3624
- const u = aiUsage();
3625
- if (u.used >= AI_DAILY) { toast(`You've used all ${AI_DAILY} AI messages today. They reset at midnight.`); return; }
3626
- let c = aiCurrent();
3627
- if (!c) { c = { id: Date.now().toString(36), title: aiTitle(text || "Picture"), ts: Date.now(), messages: [] }; ai.chats.unshift(c); ai.currentId = c.id; }
3628
- c.messages.push({ role: "user", text: text.slice(0, 4000) || "What's in this picture?", ...(ai.pendingImg ? { img: ai.pendingImg } : {}) });
3629
- c.ts = Date.now();
3630
- ai.chats = [c, ...ai.chats.filter((x) => x !== c)]; // most recent chat on top
3631
- box.value = "";
3632
- clearAiPicture();
3633
- store.set(AI_USAGE_KEY, { day: u.day, used: u.used + 1 });
3634
- ai.busy = true;
3635
- renderAi();
3636
- try {
3637
- const reply = await askAi(c.messages.slice(-16)); // the last few turns, so it remembers the conversation
3638
- c.messages.push({ role: "assistant", text: reply.text, by: reply.by });
3639
- } catch {
3640
- c.messages.push({ role: "assistant", text: "The AI is busy right now (the free limits ran out). Try again in a bit." });
3641
- }
3642
- ai.busy = false;
3643
- aiSave();
3644
- renderAi();
3645
- box.focus();
3646
- }
3647
- async function pickAiPicture(file) {
3648
- if (!file || !/^image\//.test(file.type)) return;
3649
- try {
3650
- ai.pendingImg = await shrinkPhoto(await createImageBitmap(file));
3651
- $("ai-attach-img").src = ai.pendingImg;
3652
- $("ai-attach").hidden = false;
3653
- $("ai-input").focus();
3654
- } catch { toast("Couldn't read that picture."); }
3655
- }
3656
- function clearAiPicture() { ai.pendingImg = null; $("ai-attach").hidden = true; $("ai-attach-img").removeAttribute("src"); $("ai-pic-input").value = ""; }
3657
- function bindAi() {
3658
- ai.chats = aiLoadChats();
3659
- ai.currentId = null;
3660
- $("ai-form").addEventListener("submit", (e) => sendAi(e));
3661
- $("ai-input").addEventListener("keydown", (e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); $("ai-form").requestSubmit(); } });
3662
- $("ai-input").addEventListener("input", () => { const t = $("ai-input"); t.style.height = "auto"; t.style.height = Math.min(t.scrollHeight, 180) + "px"; });
3663
- $("ai-input").addEventListener("paste", (e) => { const f = [...(e.clipboardData?.files || [])].find((x) => x.type.startsWith("image/")); if (f) { e.preventDefault(); pickAiPicture(f); } });
3664
- $("ai-new").addEventListener("click", () => { ai.currentId = null; renderAi(); $("ai-input").focus(); });
3665
- $("ai-chats").addEventListener("click", (e) => { const b = e.target.closest("[data-chat]"); if (b) { ai.currentId = b.dataset.chat; renderAi(); } });
3666
- $("ai-search").addEventListener("input", renderAiChats);
3667
- $("ai-delete").addEventListener("click", () => {
3668
- const c = aiCurrent();
3669
- if (!c || !confirm(`Delete “${c.title}”?`)) return;
3670
- ai.chats = ai.chats.filter((x) => x !== c); ai.currentId = null; aiSave(); renderAi();
3671
- });
3672
- $("ai-log").addEventListener("click", (e) => { const b = e.target.closest("[data-suggest]"); if (b) sendAi(null, b.dataset.suggest); });
3673
- $("ai-pic").addEventListener("click", () => $("ai-pic-input").click());
3674
- $("ai-pic-input").addEventListener("change", () => pickAiPicture($("ai-pic-input").files[0]));
3675
- $("ai-attach-x").addEventListener("click", clearAiPicture);
3676
- const phone = () => innerWidth <= 800; // on phones the list slides over the chat, so it starts closed
3677
- const side = (open) => { $("ai-app").classList.toggle("side-closed", !open); if (!phone()) store.set("rug-ai-side", open); };
3678
- $("ai-collapse").addEventListener("click", () => side(false));
3679
- $("ai-expand").addEventListener("click", () => side(true));
3680
- for (const id of ["ai-new", "ai-chats"]) $(id).addEventListener("click", (e) => { if (phone() && e.target.closest("button")) side(false); });
3681
- side(!phone() && store.get("rug-ai-side", true));
3682
- }
3683
-
3684
3440
  // ---------- Emoji picker ----------
3685
3441
  const EMOJI_GROUPS = [
3686
3442
  ["😀", "😀😃😄😁😆😅😂🤣🥲😊😇🙂🙃😉😌😍🥰😘😋😛😜🤪😝🤑🤗🤭🤫🤔🤐🤨😐😑😶😏😒🙄😬😮‍💨🤥😴🤤😪😮😯😲🥱😳🥺😢😭😤😠😡🤯😱😨😰🥶🥵😵‍💫🤠🥳😎🤓🧐😈👻💀☠️🤡💩🤖👽"],
@@ -4341,16 +4097,6 @@
4341
4097
 
4342
4098
  // ---------- Boot screen + auto-update ----------
4343
4099
  const boot = { el: $("boot"), fill: $("boot-fill"), msg: $("boot-msg"), ver: $("boot-ver"), timer: 0, pct: 0 };
4344
- // The "Google Classroom" screen stays about 1.8s from when the page started, then fades to the boot screen.
4345
- // Resolves once it's gone (right away when the disguise is off).
4346
- function runSplash() {
4347
- const el = $("gc-splash");
4348
- if (!el || document.documentElement.classList.contains("no-splash") || settings.disguise === "off") { el?.remove(); return Promise.resolve(); }
4349
- return new Promise((done) => setTimeout(() => {
4350
- el.classList.add("gone");
4351
- setTimeout(() => { el.remove(); done(); }, 300);
4352
- }, Math.max(0, 1800 - performance.now())));
4353
- }
4354
4100
  function startBoot() {
4355
4101
  boot.msg.textContent = "Loading…";
4356
4102
  boot.timer = setInterval(() => {
@@ -4363,6 +4109,7 @@
4363
4109
  boot.fill.style.width = "100%";
4364
4110
  if (text) boot.msg.textContent = text;
4365
4111
  setTimeout(() => boot.el.classList.add("done"), 120);
4112
+ setTimeout(() => { boot.el.hidden = true; }, 600); // gone for good once it has faded, so nothing in it keeps running
4366
4113
  }
4367
4114
 
4368
4115
  // When opened from a versioned unpkg link (e.g. an old bookmark), jump to the newest version.
@@ -4390,7 +4137,6 @@
4390
4137
  let firstVisit = false;
4391
4138
  try { firstVisit = !Object.keys(localStorage).some((k) => k.startsWith("rug-")); } catch {}
4392
4139
  loadSettings();
4393
- const splash = runSplash();
4394
4140
  startBoot();
4395
4141
  initTheme();
4396
4142
  // the side bar can be tucked away (remembered); a small tab on the left edge brings it back
@@ -4423,7 +4169,6 @@
4423
4169
  bindChatMedia();
4424
4170
  bindPolls();
4425
4171
  bindQuotes();
4426
- bindAi();
4427
4172
  bindTrivia();
4428
4173
  bindReports();
4429
4174
  startAnalytics();
@@ -4432,8 +4177,8 @@
4432
4177
  // First visit: only messages from now on count as new.
4433
4178
  if (store.get(CHAT_SEEN_KEY, null) === null) store.set(CHAT_SEEN_KEY, Date.now());
4434
4179
  if (CFG.firebase) { openChat(); startQuotes(); }
4435
- // the loading screen shows for a moment after the Classroom screen, so it doesn't just flash
4436
- const minShow = splash.then(() => new Promise((r) => setTimeout(r, 700)));
4180
+ // just long enough that the loading screen doesn't flash
4181
+ const minShow = new Promise((r) => setTimeout(r, 300));
4437
4182
  const update = newerVersionUrl(2500);
4438
4183
  try {
4439
4184
  const res = await fetch("games.json", { cache: "no-cache" });
package/config.js CHANGED
@@ -14,16 +14,6 @@ window.RUG_CONFIG = {
14
14
  // Keys that trigger panic (KeyboardEvent.key values)
15
15
  panicKeys: ["`", "]"],
16
16
 
17
- // AI chat: free keys from any of these (fill in as many as you like; it switches to the next one when a
18
- // service is out of free messages). See SETUP.md, "AI chat". Leave all "" to hide the AI.
19
- ai: {
20
- gemini: "AQ.Ab8RN6JLclrZnjK9C9Gjev9R1CNzLD9_RYNRldc4D5skYfIXCA", // aistudio.google.com → Get API key
21
- groq: "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", // console.groq.com → API Keys
22
- openrouter: "", // openrouter.ai → Keys (uses its free models)
23
- mistral: "", // console.mistral.ai → API Keys (free Experiment plan)
24
- geminiModel: "gemini-3.5-flash", // tried first; if it stops working, the next Flash model is used
25
- },
26
-
27
17
  // Google Analytics 4 measurement ID, e.g. "G-ABC123XYZ" (from analytics.google.com).
28
18
  // Leave null to turn analytics off. Shows visitors, live users and top games in YOUR GA dashboard.
29
19
  googleAnalytics: "G-6VWCQ493PZ", // property "richardsunblockedgames"
@@ -0,0 +1,134 @@
1
+ <!--
2
+ 60 Seconds! Reatomized downloaded from gn-math! at 11/13/2026
3
+
4
+ https://gn-math.dev
5
+ https://discord.gg/gn-math
6
+ -->
7
+ <!DOCTYPE html>
8
+ <html lang="en-us">
9
+ <head>
10
+ <base
11
+ href="https://raw.githubusercontent.com/freebuisness/html/main/858.html"
12
+ />
13
+ <link
14
+ rel="shortcut icon"
15
+ href="https://cdn.jsdelivr.net/gh/usheje883-maker/60-Seconds-Webport@main/Image.png"
16
+ />
17
+ <link
18
+ rel="stylesheet"
19
+ href="https://cdn.jsdelivr.net/gh/usheje883-maker/60-Seconds-Webport@main/TemplateData/style.css"
20
+ />
21
+ <script
22
+ async=""
23
+ src="https://www.googletagmanager.com/gtag/js?id=G-PXHK7Q7G3Z"
24
+ ></script>
25
+ <script>
26
+ window.dataLayer = window.dataLayer || [];
27
+ function gtag() {
28
+ dataLayer.push(arguments);
29
+ }
30
+ gtag("js", new Date());
31
+ gtag("config", "G-PXHK7Q7G3Z");
32
+ </script>
33
+ </head>
34
+ <body>
35
+ <div id="unity-container" class="unity-desktop">
36
+ <canvas id="unity-canvas"></canvas>
37
+ <div id="unity-loading-bar">
38
+ <div id="unity-logo"></div>
39
+ <div id="unity-progress-bar-empty">
40
+ <div id="unity-progress-bar-full"></div>
41
+ </div>
42
+ </div>
43
+ <div id="unity-warning"></div>
44
+ </div>
45
+ <script>
46
+ var container = document.querySelector("#unity-container");
47
+ var canvas = document.querySelector("#unity-canvas");
48
+ var loadingBar = document.querySelector("#unity-loading-bar");
49
+ var progressBarFull = document.querySelector("#unity-progress-bar-full");
50
+ var warningBanner = document.querySelector("#unity-warning");
51
+ function unityShowBanner(msg, type) {
52
+ function updateBannerVisibility() {
53
+ warningBanner.style.display = warningBanner.children.length
54
+ ? "block"
55
+ : "none";
56
+ }
57
+ var div = document.createElement("div");
58
+ div.innerHTML = msg;
59
+ warningBanner.appendChild(div);
60
+ if (type == "error") div.style = "background: red; padding: 10px;";
61
+ else {
62
+ if (type == "warning")
63
+ div.style = "background: yellow; padding: 10px;";
64
+ setTimeout(function () {
65
+ warningBanner.removeChild(div);
66
+ updateBannerVisibility();
67
+ }, 5000);
68
+ }
69
+ updateBannerVisibility();
70
+ }
71
+ var baseUrl =
72
+ "https://cdn.jsdelivr.net/gh/usheje883-maker/60-Seconds-Webport@main/";
73
+ var buildUrl = baseUrl + "Build";
74
+ var loaderUrl = buildUrl + "/Build.loader.js";
75
+ loadingBar.style.display = "block";
76
+ var dataFiles = [
77
+ "Build.data.unityweb.0",
78
+ "Build.data.unityweb.1",
79
+ "Build.data.unityweb.2",
80
+ "Build.data.unityweb.3",
81
+ "Build.data.unityweb.4",
82
+ "Build.data.unityweb.5",
83
+ ];
84
+ Promise.all(
85
+ dataFiles.map(function (f) {
86
+ return fetch(buildUrl + "/" + f).then(function (r) {
87
+ if (!r.ok) throw Error("Failed " + f);
88
+ return r.arrayBuffer();
89
+ });
90
+ }),
91
+ ).then(function (parts) {
92
+ var total = parts.reduce(function (s, b) {
93
+ return s + b.byteLength;
94
+ }, 0);
95
+ var combined = new Uint8Array(total);
96
+ var off = 0;
97
+ parts.forEach(function (buf) {
98
+ combined.set(new Uint8Array(buf), off);
99
+ off += buf.byteLength;
100
+ });
101
+ var dataBlob = URL.createObjectURL(new Blob([combined]));
102
+ var config = {
103
+ dataUrl: dataBlob,
104
+ frameworkUrl: buildUrl + "/Build.framework.js.unityweb",
105
+ codeUrl: buildUrl + "/Build.wasm.unityweb",
106
+ streamingAssetsUrl: baseUrl + "StreamingAssets",
107
+ companyName: "Robot Gentleman",
108
+ productName: "60 Seconds",
109
+ productVersion: "1.0",
110
+ showBanner: unityShowBanner,
111
+ };
112
+ if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
113
+ container.className = "unity-mobile";
114
+ config.devicePixelRatio = 1;
115
+ unityShowBanner("WebGL builds are not supported on mobile devices.");
116
+ }
117
+ var script = document.createElement("script");
118
+ script.src = loaderUrl;
119
+ script.onload = function () {
120
+ createUnityInstance(canvas, config, function (progress) {
121
+ progressBarFull.style.width = 100 * progress + "%";
122
+ })
123
+ .then(function (unityInstance) {
124
+ loadingBar.style.display = "none";
125
+ })
126
+ .catch(function (message) {
127
+ alert(message);
128
+ });
129
+ };
130
+ document.body.appendChild(script);
131
+ });
132
+ </script>
133
+ </body>
134
+ </html>