@ywkrlerche/richardwho 1.0.45 → 1.0.47
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 +126 -17
- package/games.json +1 -1
- package/index.html +5 -2
- package/logos/choppy-orc.webp +0 -0
- package/logos/ext-adarkroom.webp +0 -0
- package/logos/ext-evolve.webp +0 -0
- package/logos/ext-sharkgame.webp +0 -0
- package/logos/ext-synergism.webp +0 -0
- package/logos/ext-trimps.webp +0 -0
- package/logos/gladi-hoppers.webp +0 -0
- package/logos/gn-104.webp +0 -0
- package/logos/gn-154.webp +0 -0
- package/logos/gn-160.webp +0 -0
- package/logos/gn-191.webp +0 -0
- package/logos/gn-209.webp +0 -0
- package/logos/gn-241.webp +0 -0
- package/logos/gn-307.webp +0 -0
- package/logos/gn-360.webp +0 -0
- package/logos/gn-376.webp +0 -0
- package/logos/gn-404.webp +0 -0
- package/logos/gn-426.webp +0 -0
- package/logos/gn-435.webp +0 -0
- package/logos/gn-447.webp +0 -0
- package/logos/gn-493.webp +0 -0
- package/logos/gn-494.webp +0 -0
- package/logos/gn-515.webp +0 -0
- package/logos/gn-528.webp +0 -0
- package/logos/gn-533.webp +0 -0
- package/logos/gn-535.webp +0 -0
- package/logos/gn-537.webp +0 -0
- package/logos/gn-575.webp +0 -0
- package/logos/gn-625.webp +0 -0
- package/logos/gn-657.webp +0 -0
- package/logos/gn-662.webp +0 -0
- package/logos/gn-94.webp +0 -0
- package/package.json +1 -1
- package/style.css +54 -0
package/app.js
CHANGED
|
@@ -109,10 +109,16 @@
|
|
|
109
109
|
).join("");
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
let gridStale = false; // play counts changed while the Games page was open: re-sort next time it opens
|
|
112
113
|
function sorted(list) {
|
|
113
114
|
const by = els.sort.value;
|
|
114
115
|
const out = list.slice();
|
|
115
|
-
if (by === "
|
|
116
|
+
if (by === "popular") {
|
|
117
|
+
// most played first (counted by everyone, in Firebase); no plays yet: the hand-picked list, then A–Z
|
|
118
|
+
const picked = new Map(POPULAR.map((id, i) => [id, i]));
|
|
119
|
+
const rank = (g) => (picked.has(g.id) ? picked.get(g.id) : 1e9);
|
|
120
|
+
out.sort((a, b) => playsOf(b) - playsOf(a) || rank(a) - rank(b));
|
|
121
|
+
} else if (by === "za") out.reverse();
|
|
116
122
|
else if (by === "small") out.sort((a, b) => a.size - b.size);
|
|
117
123
|
else if (by === "big") out.sort((a, b) => b.size - a.size);
|
|
118
124
|
return out;
|
|
@@ -212,7 +218,15 @@
|
|
|
212
218
|
if (!app) return;
|
|
213
219
|
const db = app.database();
|
|
214
220
|
let t = 0;
|
|
215
|
-
db.ref("stats/plays").on("value", (s) => {
|
|
221
|
+
db.ref("stats/plays").on("value", (s) => {
|
|
222
|
+
community.plays = s.val() || {};
|
|
223
|
+
clearTimeout(t);
|
|
224
|
+
t = setTimeout(() => {
|
|
225
|
+
refreshPopular();
|
|
226
|
+
// re-sort by popularity now if Games isn't on screen; otherwise wait until it's opened again (no jumping tiles)
|
|
227
|
+
if (els.sort.value === "popular") { if (els.gamesView.hidden || scrollY < 300) renderGrid(); else gridStale = true; }
|
|
228
|
+
}, 300);
|
|
229
|
+
});
|
|
216
230
|
db.ref("stats/playing").on("value", (s) => {
|
|
217
231
|
const counts = {};
|
|
218
232
|
s.forEach((g) => { counts[g.key] = g.numChildren(); });
|
|
@@ -354,6 +368,46 @@
|
|
|
354
368
|
`<path fill="#0b2c47" d="M0 200q50-9 100 0t100 0 100 0 100 0 100 0 100 0 100 0 100 0 100 0 100 0 100 0 100 0 100 0 100 0 100 0 100 0V240H0Z"/>` +
|
|
355
369
|
`<path fill="#3a2f1c" d="M0 214C140 196 300 204 470 226L520 240H0ZM1600 208C1480 196 1340 206 1220 232L1190 240H1600Z"/>` + palm(250, 1) + palm(1440, -1.15);
|
|
356
370
|
},
|
|
371
|
+
// "Vice" (GTA 6 inspired): a pastel Miami-style waterfront in the late afternoon. Peach and pink high-rises,
|
|
372
|
+
// a hazy tower in the middle, turquoise water, lavender palm trees and a wooden dock in front.
|
|
373
|
+
vice() {
|
|
374
|
+
const r = seeded(23);
|
|
375
|
+
const tones = ["#f4b6a6", "#f2a7c3", "#cdb8ec", "#f7cfa8", "#e9a7b9", "#b9c4ee"];
|
|
376
|
+
const tower = (x, w, h, c, o = 1) => `<g opacity="${o}"><rect x="${x | 0}" y="${(190 - h) | 0}" width="${w | 0}" height="${h | 0}" fill="${c}"/>` +
|
|
377
|
+
`<rect x="${x | 0}" y="${(190 - h) | 0}" width="${w | 0}" height="${h | 0}" fill="url(#vice-win)"/>` +
|
|
378
|
+
`<rect x="${x | 0}" y="${(190 - h) | 0}" width="${Math.max(4, w * .18) | 0}" height="${h | 0}" fill="#fff" opacity=".18"/></g>`;
|
|
379
|
+
let back = "", front = "";
|
|
380
|
+
for (let x = 0; x < 1600;) { // far row: lower, paler
|
|
381
|
+
const w = 34 + r() * 50;
|
|
382
|
+
back += tower(x, w + 1, 30 + r() * 60, tones[(r() * tones.length) | 0], .55);
|
|
383
|
+
x += w;
|
|
384
|
+
}
|
|
385
|
+
for (let x = 70; x < 1600;) { // near row: taller, gaps between
|
|
386
|
+
const w = 46 + r() * 60, h = 50 + r() * 100;
|
|
387
|
+
if (x < 560 || x > 1060) front += tower(x, w, h, tones[(r() * tones.length) | 0], .95);
|
|
388
|
+
x += w + 18 + r() * 60;
|
|
389
|
+
}
|
|
390
|
+
const palm = (x, s, h) => `<g transform="translate(${x} ${214 - 122 * h}) scale(${s * h} ${h})" fill="#7564b8"><path d="M0 122C6 78 2 38 18 0" stroke="#7564b8" stroke-width="10" stroke-linecap="round" fill="none"/>` +
|
|
391
|
+
`<path d="M18 0C-8-20-40-14-58 6-34-2-10 0 18 0ZM18 0C2-30-22-42-48-38-24-30-4-18 18 0ZM18 0C22-32 44-48 70-46 48-36 30-20 18 0ZM18 0C44-16 76-12 92 10 68 0 44 0 18 0ZM18 0C40 4 58 20 62 42 48 24 34 12 18 0ZM18 0C-4 10-20 28-22 48-12 30 2 16 18 0Z"/></g>`;
|
|
392
|
+
const glints = Array.from({ length: 22 }, () => `<rect x="${(r() * 1560) | 0}" y="${(196 + r() * 40) | 0}" width="${(18 + r() * 50) | 0}" height="1.6" rx=".8" fill="#fff" opacity="${(.25 + r() * .4).toFixed(2)}"/>`).join("");
|
|
393
|
+
const planks = Array.from({ length: 9 }, (_, i) => `<path d="M${-20 + i * 46} 240L${40 + i * 30} 212" stroke="#6b4256" stroke-width="2"/>`).join("");
|
|
394
|
+
return `<defs>` +
|
|
395
|
+
`<pattern id="vice-win" width="9" height="8" patternUnits="userSpaceOnUse"><rect x="2" y="2" width="5" height="3" fill="#fff" opacity=".28"/></pattern>` +
|
|
396
|
+
`<linearGradient id="vice-haze" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fdf2c9" stop-opacity="0"/><stop offset=".6" stop-color="#ffd8b0" stop-opacity=".55"/><stop offset="1" stop-color="#ffc49a" stop-opacity=".8"/></linearGradient>` +
|
|
397
|
+
`<linearGradient id="vice-water" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#7fd6cf"/><stop offset="1" stop-color="#2f8fa8"/></linearGradient>` +
|
|
398
|
+
`<linearGradient id="vice-tall" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#b9c4ee" stop-opacity=".2"/><stop offset=".35" stop-color="#e9b3d0"/><stop offset="1" stop-color="#f4b6a6"/></linearGradient>` +
|
|
399
|
+
`<radialGradient id="vice-glare"><stop offset="0" stop-color="#fff6d8" stop-opacity=".85"/><stop offset=".35" stop-color="#ffd9b0" stop-opacity=".35"/><stop offset="1" stop-color="#ffc49a" stop-opacity="0"/></radialGradient>` +
|
|
400
|
+
`<filter id="vice-neon" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="2.4" result="b"/><feMerge><feMergeNode in="b"/><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge></filter>` +
|
|
401
|
+
`</defs>` +
|
|
402
|
+
`<rect y="40" width="1600" height="160" fill="url(#vice-haze)"/><circle cx="800" cy="172" r="230" fill="url(#vice-glare)"/>` + back +
|
|
403
|
+
`<rect x="760" y="10" width="80" height="180" fill="url(#vice-tall)"/><rect x="760" y="10" width="80" height="180" fill="url(#vice-win)" opacity=".7"/>` + front +
|
|
404
|
+
`<rect x="585" y="62" width="62" height="128" fill="#f2a7c3"/><rect x="585" y="62" width="62" height="128" fill="url(#vice-win)"/><rect x="581" y="58" width="70" height="6" fill="#e58fb0"/>` +
|
|
405
|
+
`<g filter="url(#vice-neon)" fill="#ff3d9a" font-family="Arial Black, Arial, sans-serif" font-weight="900" font-size="15" text-anchor="middle">${[..."HOTEL"].map((ch, i) => `<text x="616" y="${88 + i * 19}">${ch}</text>`).join("")}</g>` +
|
|
406
|
+
`<rect y="188" width="1600" height="52" fill="url(#vice-water)"/><path d="M0 188.5H1600" stroke="#fff" stroke-width="1.2" opacity=".5"/>${glints}` +
|
|
407
|
+
palm(400, 1, 1.25) + palm(520, -1, .95) + palm(1090, 1, 1.1) + palm(1200, -1, .8) +
|
|
408
|
+
`<g transform="translate(330 0)"><path d="M-10 240L60 206H360L330 240Z" fill="#9a6274"/><g>${planks}</g><path d="M60 206H360" stroke="#c48a98" stroke-width="2"/>` +
|
|
409
|
+
`<rect x="88" y="196" width="12" height="44" fill="#5e3a4b"/><rect x="300" y="196" width="12" height="44" fill="#5e3a4b"/></g>`;
|
|
410
|
+
},
|
|
357
411
|
school() {
|
|
358
412
|
const windows = [690, 740, 860, 910].map((x) => `<rect x="${x}" y="150" width="26" height="30" rx="2"/>`).join("");
|
|
359
413
|
return HILLS + `<g class="s-dark"><rect x="660" y="128" width="300" height="80"/><path d="M640 130L810 76 980 130Z"/><rect x="786" y="44" width="48" height="50"/><path d="M776 46L810 22 844 46Z"/><path d="M1010 208V96" stroke-width="4"/></g>` +
|
|
@@ -365,6 +419,14 @@
|
|
|
365
419
|
};
|
|
366
420
|
// items: what falls (up: floats upward instead). ground: emoji along the bottom. flags: bunting colors.
|
|
367
421
|
// fw: firework colors; they go off all holiday with fwAlways, otherwise only on the day itself.
|
|
422
|
+
function viceExtras() {
|
|
423
|
+
const bird = `<svg viewBox="0 0 40 14"><path d="M1 9q6-8 11-1 4-6 8 0M22 6q5-6 9-1 3-5 8 0" fill="none" stroke="#3b3570" stroke-width="2" stroke-linecap="round"/></svg>`;
|
|
424
|
+
const boat = `<svg viewBox="0 0 120 34"><path d="M8 20h78l14-8h-6l-10 5H58l-6-8H34l-6 8H8Z" fill="#fff"/><path d="M34 12h18l5 6H30Z" fill="#7fd6cf"/><path d="M6 21h86l-8 7H14Z" fill="#ff6fa8"/></svg>`;
|
|
425
|
+
return `<i class="v-glare"></i><i class="v-cloud c1"></i><i class="v-cloud c2"></i><i class="v-cloud c3"></i>` +
|
|
426
|
+
`<span class="v-birds b1">${bird}</span><span class="v-birds b2">${bird}</span>` +
|
|
427
|
+
`<div class="v-bridge"><i class="car a"></i><i class="car b"></i><i class="car c"></i><i class="car d"></i><i class="car e"></i></div>` +
|
|
428
|
+
`<span class="v-boat"><i class="v-wake"></i>${boat}</span>`;
|
|
429
|
+
}
|
|
368
430
|
const RWB = ["#ef4444", "#f8fafc", "#3b82f6"];
|
|
369
431
|
const FESTS = {
|
|
370
432
|
newyear: { color: "#0a0d1f", items: ["✨", "🎉", "🎊", "⭐"], ground: ["🥂", "🎆", "🍾", "🎇"], count: 60, scene: SCENES.skyline, flags: ["#facc15", "#f8fafc", "#818cf8"], fw: ["#facc15", "#f8fafc", "#818cf8", "#f472b6"], fwAlways: true },
|
|
@@ -376,6 +438,7 @@
|
|
|
376
438
|
superbowl: { color: "#07140c", items: ["🏈", "⭐", "🎉"], ground: ["🏆", "🏈", "🍕", "📣"], count: 45, scene: SCENES.football, flags: ["#fbbf24", "#f8fafc", "#4ade80"], fw: ["#fbbf24", "#f8fafc", "#4ade80"] },
|
|
377
439
|
aprilfools: { color: "#14101f", items: ["🤡", "🃏", "🙃", "🎈"], ground: ["🎩", "🐇", "🎪", "🃏"], count: 45, up: true, flags: ["#ef4444", "#facc15", "#22c55e", "#3b82f6", "#a78bfa"] },
|
|
378
440
|
summer: { color: "#0b1a2b", items: ["🫧", "✨"], ground: ["🏖️", "🍉", "🏄", "🍦"], count: 34, up: true, scene: SCENES.beach },
|
|
441
|
+
vice: { color: "#1d2559", items: ["💵", "💸"], ground: ["🏎️", "💰"], count: 20, scene: SCENES.vice, extras: viceExtras, fw: ["#ffd166", "#ff6fa8", "#7fd6cf", "#ffffff"] },
|
|
379
442
|
backtoschool: { color: "#101426", items: ["✏️", "📚", "🍎", "📐"], ground: ["🎒", "📓", "🍎", "🖍️"], count: 40, scene: SCENES.school, flags: ["#facc15", "#f87171", "#60a5fa"] },
|
|
380
443
|
};
|
|
381
444
|
const HOLIDAYS = ["halloween", "christmas", ...Object.keys(FESTS)];
|
|
@@ -388,10 +451,10 @@
|
|
|
388
451
|
thanksgiving: ["🦃", "Thanksgiving", "Happy Thanksgiving!"], christmas: ["🎄", "Christmas", "Merry Christmas!"],
|
|
389
452
|
superbowl: ["🏈", "the Super Bowl", "It's Super Bowl Sunday!"], aprilfools: ["🤡", "April Fools' Day", "Happy April Fools' Day! Nothing is broken. Probably."],
|
|
390
453
|
};
|
|
391
|
-
const SEASON_NOTES = { summer: "☀️ Summer break. Enjoy it!", backtoschool: "✏️ Welcome back to school!" };
|
|
392
|
-
const THEMES = ["auto", "black", "white"];
|
|
454
|
+
const SEASON_NOTES = { summer: "☀️ Summer break. Enjoy it!", backtoschool: "✏️ Welcome back to school!", vice: "🌴 Welcome to Leonida" };
|
|
455
|
+
const THEMES = ["auto", "black", "white", "vice"]; // Vice: a GTA 6 inspired look you pick yourself (holidays don't replace it)
|
|
393
456
|
function resolveTheme(t) {
|
|
394
|
-
return t === "black" || t === "white" ? t : (window.rugHoliday && window.rugHoliday()) || "black";
|
|
457
|
+
return t === "black" || t === "white" || t === "vice" ? t : (window.rugHoliday && window.rugHoliday()) || "black";
|
|
395
458
|
}
|
|
396
459
|
// days until this theme's big day (0 = today, negative = it has passed, null = it has none)
|
|
397
460
|
function daysToHoliday(t) {
|
|
@@ -400,7 +463,7 @@
|
|
|
400
463
|
const n = new Date();
|
|
401
464
|
return Math.round((day - new Date(n.getFullYear(), n.getMonth(), n.getDate()).getTime()) / 864e5);
|
|
402
465
|
}
|
|
403
|
-
const themeKey = (t) => `${t}:${daysToHoliday(t)}`;
|
|
466
|
+
const themeKey = (t) => `${t}:${daysToHoliday(t)}:${t === "vice" && gta6Launch()}`;
|
|
404
467
|
let shownTheme = null, shownKey = "";
|
|
405
468
|
function applySiteTheme(choice) {
|
|
406
469
|
const t = resolveTheme(choice);
|
|
@@ -419,15 +482,27 @@
|
|
|
419
482
|
renderHolidayBanner();
|
|
420
483
|
}
|
|
421
484
|
// Under the home page search: "12 days until Christmas", a greeting on the day, a countdown on New Year's Eve
|
|
485
|
+
// GTA 6 countdown: in the Vice theme the banner under the search counts down to midnight November 19, 2026,
|
|
486
|
+
// the player's own time (Rockstar unlocks it at local midnight). "Out now" for two weeks after, then the usual note.
|
|
487
|
+
const GTA6_AT = new Date(2026, 10, 19).getTime();
|
|
488
|
+
function gta6Text() {
|
|
489
|
+
const left = GTA6_AT - Date.now();
|
|
490
|
+
if (left < -14 * 864e5) return "";
|
|
491
|
+
if (left <= 0) return "🎮 GTA 6 is out now!";
|
|
492
|
+
const s = Math.floor(left / 1000), two = (n) => String(n).padStart(2, "0"), d = Math.floor(s / 86400);
|
|
493
|
+
return `🌴 GTA 6 in ${d ? d + "d " : ""}${two(Math.floor(s / 3600) % 24)}h ${two(Math.floor(s / 60) % 60)}m ${two(s % 60)}s`;
|
|
494
|
+
}
|
|
495
|
+
const gta6Launch = () => Date.now() >= GTA6_AT && Date.now() < GTA6_AT + 864e5; // launch day: extra fireworks and cash
|
|
496
|
+
setInterval(() => { if (shownTheme === "vice" && !$("view-home").hidden && !document.hidden) renderHolidayBanner(); }, 1000);
|
|
422
497
|
function renderHolidayBanner() {
|
|
423
498
|
const t = shownTheme, info = HOLIDAY_DAYS[t], left = daysToHoliday(t);
|
|
424
|
-
let text = SEASON_NOTES[t] || "";
|
|
499
|
+
let text = (t === "vice" && gta6Text()) || SEASON_NOTES[t] || "";
|
|
425
500
|
if (info && left === 0) text = t === "newyear" ? `🎉 Happy New Year ${new Date().getFullYear()}!` : `${info[0]} ${info[2]}`;
|
|
426
501
|
else if (info && left === 1 && t === "newyear") {
|
|
427
502
|
const ms = window.rugHolidayDay(t) - Date.now(), h = Math.floor(ms / 3600e3), m = Math.ceil((ms % 3600e3) / 60e3);
|
|
428
503
|
text = `🎉 New Year in ${h ? `${h}h ` : ""}${m}m`;
|
|
429
504
|
} else if (info && left > 0) text = `${info[0]} ${left} day${left === 1 ? "" : "s"} until ${info[1]}`;
|
|
430
|
-
$("holiday-banner").textContent = text;
|
|
505
|
+
if ($("holiday-banner").textContent !== text) $("holiday-banner").textContent = text;
|
|
431
506
|
$("holiday-banner").hidden = !text;
|
|
432
507
|
}
|
|
433
508
|
// a tab left open still switches when a holiday starts or ends or its big day arrives, and the countdown keeps up
|
|
@@ -446,6 +521,7 @@
|
|
|
446
521
|
$("view-home").insertAdjacentHTML("afterbegin", `<div class="festive" data-fest="${t}" aria-hidden="true">
|
|
447
522
|
${f.flags ? bunting(f.flags) : ""}
|
|
448
523
|
<svg class="festive-scene" viewBox="0 0 1600 240" preserveAspectRatio="xMidYMax slice">${f.scene ? f.scene() : HILLS}</svg>
|
|
524
|
+
${f.extras ? f.extras() : ""}
|
|
449
525
|
${f.ground.map((e, i) => `<span class="festive-prop" style="${spots[i]};--s:${i % 2 ? 40 : 54}px;animation-delay:${i * -1.3}s">${e}</span>`).join("")}
|
|
450
526
|
</div>`);
|
|
451
527
|
}
|
|
@@ -461,7 +537,7 @@
|
|
|
461
537
|
this.kind = theme === "christmas" ? "snow" : fall ? "emoji" : null;
|
|
462
538
|
if (!this.kind) { cancelAnimationFrame(this.raf); this.raf = 0; if (this.canvas) this.canvas.hidden = true; return; }
|
|
463
539
|
if (!this.canvas) this.init();
|
|
464
|
-
const big = daysToHoliday(theme) === 0; // the day itself: more of everything
|
|
540
|
+
const big = daysToHoliday(theme) === 0 || (theme === "vice" && gta6Launch()); // the day itself: more of everything
|
|
465
541
|
this.items = fall?.items || [];
|
|
466
542
|
this.dir = fall?.up ? -1 : 1;
|
|
467
543
|
this.fw = fall?.fw && (fall.fwAlways || big) ? fall.fw : null;
|
|
@@ -703,23 +779,35 @@
|
|
|
703
779
|
await new Promise((r) => setTimeout(r, 600 * attempt));
|
|
704
780
|
}
|
|
705
781
|
loaded[i] = 0;
|
|
782
|
+
// A source that goes quiet (jsDelivr sometimes just hangs on big files) is dropped for the next one:
|
|
783
|
+
// nothing for 6s at the start, or nothing for 15s partway through
|
|
784
|
+
const attemptCtl = new AbortController();
|
|
785
|
+
const stopAttempt = () => attemptCtl.abort();
|
|
786
|
+
controller.signal.addEventListener("abort", stopAttempt);
|
|
787
|
+
let stall = setTimeout(stopAttempt, 6000);
|
|
788
|
+
const progress = () => { clearTimeout(stall); stall = setTimeout(stopAttempt, 15000); };
|
|
706
789
|
try {
|
|
707
|
-
const res = await fetch(sources[attempt], { signal:
|
|
790
|
+
const res = await fetch(sources[attempt], { signal: attemptCtl.signal });
|
|
708
791
|
if (!res.ok) throw new Error(`HTTP ${res.status} for ${url.split("/").pop()}`);
|
|
792
|
+
progress();
|
|
709
793
|
if (!res.body) { const b = await res.arrayBuffer(); loaded[i] = b.byteLength; update(); return [b]; }
|
|
710
794
|
const reader = res.body.getReader();
|
|
711
795
|
const chunks = [];
|
|
712
796
|
for (;;) {
|
|
713
797
|
const { done, value } = await reader.read();
|
|
714
798
|
if (done) break;
|
|
799
|
+
progress();
|
|
715
800
|
chunks.push(value);
|
|
716
801
|
loaded[i] += value.byteLength;
|
|
717
802
|
update();
|
|
718
803
|
}
|
|
719
804
|
return chunks;
|
|
720
805
|
} catch (err) {
|
|
721
|
-
if (
|
|
722
|
-
lastErr = err;
|
|
806
|
+
if (controller.signal.aborted) throw new DOMException("Aborted", "AbortError"); // the player left
|
|
807
|
+
lastErr = err.name === "AbortError" ? new Error("the download stalled") : err;
|
|
808
|
+
} finally {
|
|
809
|
+
clearTimeout(stall);
|
|
810
|
+
controller.signal.removeEventListener("abort", stopAttempt);
|
|
723
811
|
}
|
|
724
812
|
}
|
|
725
813
|
throw lastErr;
|
|
@@ -791,14 +879,14 @@
|
|
|
791
879
|
};
|
|
792
880
|
|
|
793
881
|
// Backup sources for a jsDelivr GitHub link, in the order to try them:
|
|
794
|
-
// the
|
|
882
|
+
// the link itself, GitHub's own file server, jsDelivr's second network, then the link once more.
|
|
795
883
|
// The extra collection's files are also published as gn-math/html at the same commit.
|
|
796
884
|
function mirrorsFor(url) {
|
|
797
885
|
const m = url.match(/^https:\/\/cdn\.jsdelivr\.net\/gh\/([^/]+)\/([^@/]+)@([^/]+)\/(.+)$/);
|
|
798
886
|
if (!m) return [url, url];
|
|
799
887
|
const [, user, repo, ref, path] = m;
|
|
800
|
-
const list = [url,
|
|
801
|
-
`https://
|
|
888
|
+
const list = [url, `https://raw.githubusercontent.com/${user}/${repo}/${ref}/${path}`,
|
|
889
|
+
`https://fastly.jsdelivr.net/gh/${user}/${repo}@${ref}/${path}`, url];
|
|
802
890
|
if (user === "freebuisness" && repo === "html") {
|
|
803
891
|
list.push(`https://cdn.jsdelivr.net/gh/gn-math/html@${ref}/${path}`,
|
|
804
892
|
`https://raw.githubusercontent.com/gn-math/html/${ref}/${path}`);
|
|
@@ -827,6 +915,25 @@
|
|
|
827
915
|
// or pushState() would move the whole tab (and kick the player out). Give games no-op versions first.
|
|
828
916
|
const HISTORY_GUARD = "<script>(function(){try{var h=window.history,n=function(){};" +
|
|
829
917
|
"h.back=h.forward=h.go=h.pushState=h.replaceState=n;}catch(e){}})();<\/script>";
|
|
918
|
+
// Games download their own files from other people's GitHub repos through jsDelivr, which sometimes just
|
|
919
|
+
// hangs on big files (game engines, data packs). Inside every game: big files come straight from GitHub's
|
|
920
|
+
// file server (jsDelivr as the fallback); everything else tries jsDelivr and switches to GitHub after 6s.
|
|
921
|
+
const NET_GUARD = "<script>(function(){try{" +
|
|
922
|
+
"var re=/^https:\\/\\/(?:cdn|fastly)\\.jsdelivr\\.net\\/gh\\/([^\\/@]+)\\/([^\\/@]+)(?:@([^\\/]+))?\\/([^?#]+)/;" +
|
|
923
|
+
"var big=/\\.(wasm|data|unityweb|unity3d|pck|bin|br|gz|swf|mem|zip|obb|bundle)(\\?|#|$)/i;" +
|
|
924
|
+
"function abs(u){try{return new URL(u,document.baseURI).href}catch(e){return String(u)}}" +
|
|
925
|
+
"function gh(u){var m=re.exec(u);return m?'https://raw.githubusercontent.com/'+m[1]+'/'+m[2]+'/'+(m[3]||'HEAD')+'/'+m[4]:null}" +
|
|
926
|
+
"function good(r){if(!r.ok||/text\\/html/i.test(r.headers.get('content-type')||''))throw new Error('bad');return r}" +
|
|
927
|
+
"var F=window.fetch;if(F)window.fetch=function(input,init){" +
|
|
928
|
+
"var u=abs(typeof input==='string'?input:input&&input.url),alt=gh(u);if(!alt)return F.apply(this,arguments);" +
|
|
929
|
+
"if(big.test(u))return F.call(window,alt,init).then(good).catch(function(){return F.call(window,u,init)});" +
|
|
930
|
+
"return new Promise(function(ok,no){var settled=false;function backup(){if(settled)return;settled=true;F.call(window,alt,init).then(ok,no)}" +
|
|
931
|
+
"var t=setTimeout(backup,6000);F.call(window,input,init).then(function(r){clearTimeout(t);if(settled)return;if(r.ok){settled=true;ok(r)}else backup()},function(){clearTimeout(t);backup()})})};" +
|
|
932
|
+
"var O=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(m,u){var a=abs(u),alt=gh(a);if(alt&&big.test(a))arguments[1]=alt;return O.apply(this,arguments)};" +
|
|
933
|
+
// a game's helper worker script lives on jsDelivr, which browsers refuse to start directly: start it through a tiny local loader
|
|
934
|
+
"var W=window.Worker;if(W)window.Worker=function(u,o){var a=abs(u);if(/^https?:/.test(a)&&new URL(a).origin!==location.origin){" +
|
|
935
|
+
"u=URL.createObjectURL(new Blob(['importScripts('+JSON.stringify(a)+')'],{type:'text/javascript'}))}return new W(u,o)};window.Worker.prototype=W.prototype;" +
|
|
936
|
+
"}catch(e){}})();<\/script>";
|
|
830
937
|
// Insert only at the very top of the file (after an optional doctype and <html> tag). Searching for the
|
|
831
938
|
// first "<head>" anywhere is unsafe: many self-unpacking games keep their whole page inside a script string,
|
|
832
939
|
// and inserting there cuts that string in half.
|
|
@@ -834,7 +941,7 @@
|
|
|
834
941
|
function guardHistory(html, base) {
|
|
835
942
|
const top = html.match(/^(?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>)?\s*(?:<html\b[^>]*>)?)/i)[1];
|
|
836
943
|
const baseTag = base ? `<base href="${base.replace(/"/g, """)}">` : "";
|
|
837
|
-
return top + baseTag + HISTORY_GUARD + html.slice(top.length);
|
|
944
|
+
return top + baseTag + HISTORY_GUARD + NET_GUARD + html.slice(top.length);
|
|
838
945
|
}
|
|
839
946
|
|
|
840
947
|
function stopGame() {
|
|
@@ -923,7 +1030,7 @@
|
|
|
923
1030
|
track(view[0].toUpperCase() + view.slice(1));
|
|
924
1031
|
document.querySelectorAll(".rail-btn[data-nav]").forEach((b) =>
|
|
925
1032
|
b.classList.toggle("active", b.dataset.nav === (location.hash === "#recent" ? "recent" : view)));
|
|
926
|
-
if (view === "games") renderRecent();
|
|
1033
|
+
if (view === "games") { renderRecent(); if (gridStale) { gridStale = false; renderGrid(); } }
|
|
927
1034
|
if (location.hash === "#recent") requestAnimationFrame(() => els.recentBlock.scrollIntoView({ block: "start" }));
|
|
928
1035
|
}
|
|
929
1036
|
function play(id) { location.hash = `#play/${encodeURIComponent(id)}`; }
|
|
@@ -986,6 +1093,8 @@
|
|
|
986
1093
|
// Newest first. Add an entry here with every publish; its version should match package.json.
|
|
987
1094
|
// Each has: new (features), games (added/removed/fixed games), fixes (bugs). Leave a list out if empty.
|
|
988
1095
|
const CHANGELOG = [
|
|
1096
|
+
{ version: "1.0.47", date: "2026-11-16",
|
|
1097
|
+
new: ["🌴 New theme: Vice, a pastel waterfront inspired by GTA 6, with boats, birds, clouds and a busy causeway. It's on for everyone during GTA 6 launch week", "⏳ A GTA 6 countdown on the home page, with fireworks on launch day (November 19)", "🔥 The Games page now lists the most played games first (switch to A–Z in the sort menu)", "🎮 29 new games, including Freddy Fazbear's Pizzeria Simulator, Evolve, Trimps, Synergism, Shark Game, A Dark Room, Going Balls and RigBMX"], fixes: ["Fixed big games getting stuck on loading forever (Angry Birds, Retro Bowl College, Vex X3M and more): when the main download server stalls, the site now switches to a backup within seconds", "Fixed games that got stuck partway through loading their own files (Build a Queen and other 3D games)", "Gladi Hoppers and Choppy Orc have their real pictures", "2048 Merge Run was removed: its game files were deleted by their owner"] },
|
|
989
1098
|
{ version: "1.0.45", date: "2026-11-13",
|
|
990
1099
|
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"] },
|
|
991
1100
|
{ version: "1.0.44", date: "2026-11-12",
|