@indextools/index-games 1.0.1 → 1.0.2

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/public/index.svg CHANGED
@@ -1,53 +1,1159 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 100 100">
3
- <foreignObject width="100%" height="100%">
4
- <html xmlns="http://www.w3.org/1999/xhtml" style="width:100%; height:100%; margin:0; padding:0;">
5
- <head>
6
- <title>Index</title>
7
- <style>
8
- * { margin: 0; padding: 0; box-sizing: border-box; }
9
- html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0c10; }
10
- iframe { width: 100vw; height: 100vh; border: none; display: block; position: fixed; inset: 0; }
11
- .fallback-link {
12
- position: fixed;
13
- top: 10px;
14
- right: 10px;
15
- z-index: 99999;
16
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
17
- font-size: 13px;
18
- color: #45f3ff;
19
- background: rgba(11, 12, 16, 0.9);
20
- border: 1px solid #45f3ff;
21
- padding: 6px 14px;
22
- border-radius: 6px;
23
- text-decoration: none;
24
- backdrop-filter: blur(4px);
25
- }
26
- </style>
27
- </head>
28
- <body>
29
- <a id="index-link" class="fallback-link" href="index.html" target="_top">Launch Index</a>
30
- <iframe id="index-frame" src="index.html" allowfullscreen="true" sandbox="allow-scripts allow-same-origin allow-forms allow-modals allow-downloads"></iframe>
31
- </body>
32
- </html>
33
- </foreignObject>
34
- <script type="text/javascript">
35
- <![CDATA[
36
- (function() {
37
- try {
38
- var frame = document.getElementById("index-frame");
39
- var link = document.getElementById("index-link");
40
- var path = (typeof window !== "undefined" && window.location && window.location.pathname) || "";
41
- var target = "index.html";
42
- if (path && !path.includes("/public/") && !path.endsWith("/public")) {
43
- target = "public/index.html";
44
- }
45
- if (frame && !frame.getAttribute("src")) frame.src = target;
46
- if (link) link.href = target;
47
- } catch (e) {
48
- console.error(e);
49
- }
50
- })();
51
- ]]>
52
- </script>
53
- </svg>
2
+ <svg xmlns="http://www.w3.org/2000/svg"
3
+ xmlns:html="http://www.w3.org/1999/xhtml"
4
+ width="100%" height="100%"
5
+ viewBox="0 0 1920 1080">
6
+
7
+ <foreignObject x="0" y="0" width="1920" height="1080">
8
+
9
+ <html:div style="width:100%;height:100%;">
10
+
11
+ <!doctype html>
12
+ <html>
13
+ <head>
14
+ <meta charset="utf-8" />
15
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
16
+ <title>Index</title>
17
+
18
+ <script src="config.js"></script>
19
+ <script src="https://unpkg.com/@titaniumnetwork-dev/ultraviolet@3.2.10/dist/uv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@titaniumnetwork-dev/ultraviolet@3.2.10/dist/uv.config.js"></script>
21
+ <script src="https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js"></script>
22
+ <script src="https://unpkg.com/@mercuryworkshop/bare-mux@2.1.7/dist/index.js"></script>
23
+
24
+ <link rel="stylesheet" href="index.css" />
25
+ <script src="register-sw.js" defer></script>
26
+ <script src="search.js" defer></script>
27
+ </head>
28
+
29
+ <body>
30
+ <canvas id="bg-canvas"></canvas>
31
+
32
+ <div id="game-modal">
33
+ <div class="game-modal-bar">
34
+ <span class="game-modal-name" id="gm-name"></span>
35
+ <span class="game-modal-file" id="gm-file"></span>
36
+ <div class="game-modal-actions">
37
+ <button class="game-modal-btn" id="gm-fullscreen">⛶ fullscreen</button>
38
+ <button class="game-modal-btn close-btn" id="gm-close">✕ back to games</button>
39
+ </div>
40
+ </div>
41
+ <iframe class="game-modal-iframe" id="gm-iframe" allowfullscreen
42
+ sandbox="allow-scripts allow-same-origin allow-forms allow-modals"></iframe>
43
+ </div>
44
+
45
+ <div id="app">
46
+ <div id="tab-bar">
47
+ <button id="new-tab-btn" title="New tab">+</button>
48
+ <button id="games-btn" title="Games">🎮 games</button>
49
+ <button id="apps-btn" title="Apps">🗂 apps</button>
50
+ <!-- settings button removed from tab bar — now a FAB -->
51
+ </div>
52
+ <div id="main-area">
53
+ <div id="tab-content"></div>
54
+ <div id="settings-panel"></div><!-- kept for legacy JS, hidden via CSS -->
55
+ </div>
56
+ </div>
57
+
58
+ <!-- ── SETTINGS FAB ── -->
59
+ <button id="settings-fab" title="Settings">⚙</button>
60
+
61
+ <!-- ── SETTINGS DRAWER OVERLAY ── -->
62
+ <div id="settings-overlay">
63
+ <div id="settings-drawer">
64
+
65
+ <!-- topbar (dynamic) -->
66
+ <div class="drawer-topbar" id="drawer-topbar">
67
+ <button class="drawer-back-btn" id="drawer-back" style="display:none">← back</button>
68
+ <span class="drawer-page-title" id="drawer-title">// settings</span>
69
+ <button class="drawer-close-btn" id="drawer-close" title="Close">✕</button>
70
+ </div>
71
+
72
+ <div class="drawer-body">
73
+
74
+ <!-- PAGE: main -->
75
+ <div class="drawer-page active" id="dpage-main">
76
+ <div class="settings-nav">
77
+ <div class="settings-nav-item" data-goto="dpage-appearance">
78
+ <span class="settings-nav-icon">🎨</span>
79
+ <div>
80
+ <div>Appearance</div>
81
+ <div class="settings-nav-desc">themes &amp; visual style</div>
82
+ </div>
83
+ <span class="settings-nav-arrow">›</span>
84
+ </div>
85
+ <div class="settings-nav-item" data-goto="dpage-cloak">
86
+ <span class="settings-nav-icon">🔒</span>
87
+ <div>
88
+ <div>Tab Cloak</div>
89
+ <div class="settings-nav-desc">disguise tab title &amp; icon</div>
90
+ </div>
91
+ <span class="settings-nav-arrow">›</span>
92
+ </div>
93
+ <div class="settings-nav-item" data-goto="dpage-privacy">
94
+ <span class="settings-nav-icon">🌐</span>
95
+ <div>
96
+ <div>Privacy</div>
97
+ <div class="settings-nav-desc">about:blank &amp; proxy</div>
98
+ </div>
99
+ <span class="settings-nav-arrow">›</span>
100
+ </div>
101
+ <div class="settings-nav-item" data-goto="dpage-about">
102
+ <span class="settings-nav-icon">ℹ</span>
103
+ <div>
104
+ <div>About</div>
105
+ <div class="settings-nav-desc">version, proxy, credits</div>
106
+ </div>
107
+ <span class="settings-nav-arrow">›</span>
108
+ </div>
109
+ </div>
110
+
111
+ <!--<div class="dsection-label">community</div>
112
+ <a href="https://discord.gg/TYPE_HERE" target="_blank" class="drawer-link-btn discord-btn">
113
+ <div class="discord-icon">D</div>
114
+ <div>
115
+ <div>Join our Discord</div>
116
+ <div style="font-size:10px;color:#7289da;margin-top:2px;">discord.gg/TYPE_HERE</div>
117
+ </div>
118
+ <span class="settings-nav-arrow" style="margin-left:auto">↗</span>
119
+ </a>-->
120
+ </div>
121
+
122
+ <!-- PAGE: appearance (themes) -->
123
+ <div class="drawer-page" id="dpage-appearance">
124
+ <div class="dsection-label">theme</div>
125
+ <div class="theme-options" id="theme-options">
126
+ <div class="theme-option selected" data-theme="default">
127
+ <div class="theme-swatch swatch-default"></div>
128
+ <div>
129
+ <div style="font-size:11px;color:var(--text-bright)">Index's Theme</div>
130
+ <div style="font-size:9px;color:var(--text-muted)">green terminal</div>
131
+ </div>
132
+ </div>
133
+ <div class="theme-option" data-theme="nexora">
134
+ <div class="theme-swatch swatch-nexora"></div>
135
+ <div>
136
+ <div style="font-size:11px;color:var(--text-bright)">Nexora</div>
137
+ <div style="font-size:9px;color:var(--text-muted)">orange + stars</div>
138
+ </div>
139
+ </div>
140
+ <div class="theme-option" data-theme="wave">
141
+ <div class="theme-swatch swatch-wave"></div>
142
+ <div>
143
+ <div style="font-size:11px;color:var(--text-bright)">Aspen's Theme</div>
144
+ <div style="font-size:9px;color:var(--text-muted)">flowing lines</div>
145
+ </div>
146
+ </div>
147
+ <div class="theme-option" data-theme="void">
148
+ <div class="theme-swatch swatch-void"></div>
149
+ <div>
150
+ <div style="font-size:11px;color:var(--text-bright)">Void</div>
151
+ <div style="font-size:9px;color:var(--text-muted)">black + white waves</div>
152
+ </div>
153
+ </div>
154
+ <div class="theme-option" data-theme="fern">
155
+ <div class="theme-swatch swatch-fern"></div>
156
+ <div>
157
+ <div style="font-size:11px;color:var(--text-bright)">Fern's Theme</div>
158
+ <div style="font-size:9px;color:var(--text-muted)">stars + constellations</div>
159
+ </div>
160
+ </div>
161
+ </div>
162
+ </div>
163
+
164
+ <!-- PAGE: cloak -->
165
+ <div class="drawer-page" id="dpage-cloak">
166
+ <div class="dsection-label">tab cloak</div>
167
+ <div class="cloak-options" id="cloak-options">
168
+ <div class="cloak-option selected" data-title="Index" data-favicon="" data-cloak="none">
169
+ <div class="cloak-option-icon">🌿</div>
170
+ <div class="cloak-option-info"><div class="cloak-option-name">None</div><div class="cloak-option-url">default</div></div>
171
+ </div>
172
+ <div class="cloak-option" data-title="Google" data-favicon="https://www.google.com/favicon.ico" data-cloak="google">
173
+ <div class="cloak-option-icon">🔍</div>
174
+ <div class="cloak-option-info"><div class="cloak-option-name">Google</div><div class="cloak-option-url">google.com</div></div>
175
+ </div>
176
+ <div class="cloak-option" data-title="Google Classroom" data-favicon="https://ssl.gstatic.com/classroom/favicon.png" data-cloak="classroom">
177
+ <div class="cloak-option-icon">🎓</div>
178
+ <div class="cloak-option-info"><div class="cloak-option-name">Google Classroom</div><div class="cloak-option-url">classroom.google.com</div></div>
179
+ </div>
180
+ <div class="cloak-option" data-title="Clever" data-favicon="https://assets.clever.com/resource-icons/apps/favicon.ico" data-cloak="clever">
181
+ <div class="cloak-option-icon">📚</div>
182
+ <div class="cloak-option-info"><div class="cloak-option-name">Clever</div><div class="cloak-option-url">clever.com</div></div>
183
+ </div>
184
+ <div class="cloak-option" data-title="Khan Academy" data-favicon="https://www.khanacademy.org/favicon.ico" data-cloak="khan">
185
+ <div class="cloak-option-icon">🟢</div>
186
+ <div class="cloak-option-info"><div class="cloak-option-name">Khan Academy</div><div class="cloak-option-url">khanacademy.org</div></div>
187
+ </div>
188
+ <div class="cloak-option" data-title="Schoology" data-favicon="https://asset-cdn.schoology.com/sites/all/themes/schoology_theme/favicon.ico" data-cloak="schoology">
189
+ <div class="cloak-option-icon">📝</div>
190
+ <div class="cloak-option-info"><div class="cloak-option-name">Schoology</div><div class="cloak-option-url">schoology.com</div></div>
191
+ </div>
192
+ </div>
193
+ <div class="dsection-note">changes the tab title and favicon — won't affect other users.</div>
194
+ </div>
195
+
196
+ <!-- PAGE: privacy -->
197
+ <div class="drawer-page" id="dpage-privacy">
198
+ <div class="dsection-label">about:blank</div>
199
+ <button class="ab-btn" id="ab-btn">
200
+ <span class="ab-btn-icon">⬡</span>
201
+ <div>
202
+ <div class="ab-btn-name">Open in about:blank</div>
203
+ <div class="ab-btn-desc">hides the url in a blank popup window</div>
204
+ </div>
205
+ </button>
206
+ <div class="dsection-note">opens proxy pages in a popup showing about:blank in the address bar.</div>
207
+ </div>
208
+
209
+ <!-- PAGE: about -->
210
+ <div class="drawer-page" id="dpage-about">
211
+ <div class="about-logo">
212
+ <div class="about-logo-mark">⬡</div>
213
+ <div>
214
+ <div class="about-logo-name">Index</div>
215
+ <div class="about-logo-tag">web proxy &amp; browser</div>
216
+ </div>
217
+ </div>
218
+
219
+ <div class="about-desc">
220
+ Index is a proxy website, used for bypassing school restrictions and accessing blocked content. We use iframes, so some sitese may not load images and/or videos. Join the discord for many suggestings, or any issues/questions you have!
221
+ </div>
222
+
223
+ <div class="about-row">
224
+ <span class="about-row-label">proxy engine</span>
225
+ <span class="about-row-val">ScramJet {experimental}<span class="about-badge">active</span></span>
226
+ </div>
227
+ <div class="about-row">
228
+ <span class="about-row-label">version</span>
229
+ <span class="about-row-val">v0.0.6</span>
230
+ </div>
231
+ <div class="about-row">
232
+ <span class="about-row-label">max tabs</span>
233
+ <span class="about-row-val">20</span>
234
+ </div>
235
+
236
+ <div class="dsection-label" style="margin-top:20px;">scramjet</div>
237
+ <div class="about-desc">
238
+ best proxt!
239
+ </div>
240
+
241
+ <!--<a href="https://discord.gg/TYPE_HERE" target="_blank" class="drawer-link-btn discord-btn" style="margin-top:4px;">
242
+ <div class="discord-icon">D</div>
243
+ <div>
244
+ <div>Join our Discord</div>
245
+ <div style="font-size:10px;color:#7289da;margin-top:2px;">community &amp; support</div>
246
+ </div>
247
+ <span style="margin-left:auto;color:var(--text-dim)">↗</span>
248
+ </a>
249
+ </div>-->
250
+
251
+ </div><!-- /drawer-body -->
252
+ </div><!-- /settings-drawer -->
253
+ </div><!-- /settings-overlay -->
254
+
255
+ <script>
256
+ "use strict";
257
+
258
+ /* ══════════════════════════════════════════
259
+ CANVAS / THEMES (unchanged from original)
260
+ ══════════════════════════════════════════ */
261
+ const canvas = document.getElementById("bg-canvas");
262
+ const ctx = canvas.getContext("2d");
263
+ let currentTheme = "default";
264
+ let animFrame = null;
265
+ let mouseX = 0, mouseY = 0;
266
+
267
+ const stars = Array.from({length: 180}, () => ({
268
+ x: Math.random(), y: Math.random(),
269
+ r: Math.random() * 2 + 0.3,
270
+ speed: Math.random() * 0.00015 + 0.00005,
271
+ drift: (Math.random() - 0.5) * 0.0001,
272
+ opacity: Math.random() * 0.7 + 0.3
273
+ }));
274
+
275
+ const LINE_COUNT = 51;
276
+ const waveLines = Array.from({length: LINE_COUNT}, (_, i) => {
277
+ const points = 120;
278
+ return {
279
+ baseY: (i + 1) / (LINE_COUNT + 1),
280
+ points: Array.from({length: points}, (_, j) => ({
281
+ x: j / (points - 1),
282
+ offset: Math.random() * Math.PI * 2,
283
+ speed: 0.003 + Math.random() * 0.002,
284
+ amp: 0.012 + Math.random() * 0.018,
285
+ mouseInfluence: 0
286
+ }))
287
+ };
288
+ });
289
+ let waveT = 0;
290
+
291
+ const fernNodes = Array.from({length: 40}, () => ({
292
+ x: Math.random() * window.innerWidth,
293
+ y: Math.random() * window.innerHeight,
294
+ vx: (Math.random() - 0.5) * 0.3,
295
+ vy: (Math.random() - 0.5) * 0.3,
296
+ r: Math.random() * 1.5 + 0.5,
297
+ }));
298
+
299
+ const fernStars = Array.from({length: 120}, () => ({
300
+ x: Math.random(), y: Math.random(),
301
+ r: Math.random() * 1.2 + 0.3,
302
+ opacity: Math.random() * 0.6 + 0.2,
303
+ twinkleOffset: Math.random() * Math.PI * 2,
304
+ }));
305
+
306
+ let shootingStars = [];
307
+ let fernShootingTimer = 0;
308
+
309
+ function spawnShootingStar() {
310
+ shootingStars.push({
311
+ x: Math.random() * canvas.width,
312
+ y: Math.random() * canvas.height * 0.5,
313
+ len: 80 + Math.random() * 120,
314
+ speed: 8 + Math.random() * 6,
315
+ angle: Math.PI / 5 + (Math.random() - 0.5) * 0.3,
316
+ life: 1.0,
317
+ decay: 0.018 + Math.random() * 0.012,
318
+ });
319
+ }
320
+
321
+ canvas.addEventListener("click", function(e) {
322
+ if (currentTheme !== "fern") return;
323
+ for (let i = 0; i < 3; i++) {
324
+ shootingStars.push({
325
+ x: e.clientX - 30 + Math.random() * 60,
326
+ y: e.clientY - 20 + Math.random() * 40,
327
+ len: 60 + Math.random() * 100,
328
+ speed: 6 + Math.random() * 8,
329
+ angle: Math.PI / 5 + (Math.random() - 0.5) * 0.6,
330
+ life: 1.0,
331
+ decay: 0.022 + Math.random() * 0.015,
332
+ });
333
+ }
334
+ });
335
+
336
+ window.addEventListener("mousemove", e => {
337
+ mouseX = e.clientX / window.innerWidth;
338
+ mouseY = e.clientY / window.innerHeight;
339
+ });
340
+
341
+ function resizeCanvas() {
342
+ canvas.width = window.innerWidth;
343
+ canvas.height = window.innerHeight;
344
+ }
345
+ window.addEventListener("resize", resizeCanvas);
346
+ resizeCanvas();
347
+
348
+ function drawNexora() {
349
+ const W = canvas.width, H = canvas.height;
350
+ ctx.clearRect(0, 0, W, H);
351
+ const grad = ctx.createRadialGradient(W*0.4, H*0.5, 0, W*0.5, H*0.5, W*0.8);
352
+ grad.addColorStop(0, "rgba(30,10,0,0.95)");
353
+ grad.addColorStop(1, "rgba(5,2,0,0.98)");
354
+ ctx.fillStyle = grad;
355
+ ctx.fillRect(0, 0, W, H);
356
+ for (const s of stars) {
357
+ s.x += s.speed; s.y += s.drift;
358
+ if (s.x > 1) s.x = 0;
359
+ if (s.y > 1) s.y = 0;
360
+ if (s.y < 0) s.y = 1;
361
+ const sx = s.x * W, sy = s.y * H;
362
+ const twinkle = 0.5 + 0.5 * Math.sin(Date.now() * 0.002 * s.speed * 300 + s.offset || 0);
363
+ ctx.beginPath();
364
+ ctx.arc(sx, sy, s.r, 0, Math.PI * 2);
365
+ ctx.fillStyle = `rgba(255,220,180,${s.opacity * (0.6 + 0.4 * twinkle)})`;
366
+ ctx.fill();
367
+ }
368
+ const orb = ctx.createRadialGradient(W*0.35, H*0.55, 0, W*0.35, H*0.55, W*0.45);
369
+ orb.addColorStop(0, "rgba(255,80,0,0.12)");
370
+ orb.addColorStop(0.5, "rgba(255,40,0,0.05)");
371
+ orb.addColorStop(1, "transparent");
372
+ ctx.fillStyle = orb;
373
+ ctx.fillRect(0, 0, W, H);
374
+ animFrame = requestAnimationFrame(drawNexora);
375
+ }
376
+
377
+ function drawWave() {
378
+ const W = canvas.width, H = canvas.height;
379
+ ctx.clearRect(0, 0, W, H);
380
+ ctx.fillStyle = "#1a2530";
381
+ ctx.fillRect(0, 0, W, H);
382
+ waveT += 0.004;
383
+ const TOTAL_LINES = 120;
384
+ for (let li = 0; li < TOTAL_LINES; li++) {
385
+ const t = li / TOTAL_LINES;
386
+ const isAccent = li >= TOTAL_LINES - 4;
387
+ const accentStrength = isAccent ? (li - (TOTAL_LINES - 4)) / 4 : 0;
388
+ const baseColor = isAccent
389
+ ? `rgba(${80 + accentStrength * 100},${180 + accentStrength * 60},${80 + accentStrength * 20},${0.4 + accentStrength * 0.5})`
390
+ : `rgba(60,100,75,${0.06 + t * 0.12})`;
391
+ ctx.beginPath();
392
+ ctx.strokeStyle = baseColor;
393
+ ctx.lineWidth = isAccent ? 1.5 + accentStrength * 1.5 : 0.6;
394
+ const STEPS = 300;
395
+ for (let si = 0; si <= STEPS; si++) {
396
+ const x = (si / STEPS) * W;
397
+ const px = si / STEPS;
398
+ const dx = px - mouseX, dy = t - mouseY;
399
+ const dist = Math.sqrt(dx * dx + dy * dy * 4);
400
+ const repel = dist < 0.12 ? (0.12 - dist) / 0.12 : 0;
401
+ const repelDir = t < mouseY ? -1 : 1;
402
+ const w1 = Math.sin(px * 5 + waveT * 1.1 + li * 0.18) * 0.028;
403
+ const w2 = Math.sin(px * 11 - waveT * 0.7 + li * 0.31) * 0.014;
404
+ const w3 = Math.sin(px * 2 + waveT * 0.4 + li * 0.09) * 0.045;
405
+ const w4 = Math.sin(px * 18 + waveT * 1.8 + li * 0.55) * 0.006;
406
+ const baseY = t + 0.02;
407
+ const y = (baseY + w1 + w2 + w3 + w4 + repel * repelDir * 0.06) * H;
408
+ if (si === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
409
+ }
410
+ ctx.stroke();
411
+ }
412
+ animFrame = requestAnimationFrame(drawWave);
413
+ }
414
+
415
+ let voidT = 0;
416
+ function drawVoid() {
417
+ const W = canvas.width, H = canvas.height;
418
+ ctx.clearRect(0, 0, W, H);
419
+ ctx.fillStyle = "#000000";
420
+ ctx.fillRect(0, 0, W, H);
421
+ voidT += 0.004;
422
+ const TOTAL_LINES = 100;
423
+ for (let li = 0; li < TOTAL_LINES; li++) {
424
+ const t = li / TOTAL_LINES;
425
+ const isAccent = li >= TOTAL_LINES - 3;
426
+ const accentStrength = isAccent ? (li - (TOTAL_LINES - 3)) / 3 : 0;
427
+ const alpha = isAccent ? 0.55 + accentStrength * 0.45 : 0.04 + t * 0.18;
428
+ ctx.beginPath();
429
+ ctx.strokeStyle = `rgba(255,255,255,${alpha})`;
430
+ ctx.lineWidth = isAccent ? 1.2 + accentStrength * 1.0 : 0.5;
431
+ const STEPS = 300;
432
+ for (let si = 0; si <= STEPS; si++) {
433
+ const x = (si / STEPS) * W;
434
+ const px = si / STEPS;
435
+ const dx = px - mouseX, dy = t - mouseY;
436
+ const dist = Math.sqrt(dx * dx + dy * dy * 4);
437
+ const repel = dist < 0.12 ? (0.12 - dist) / 0.12 : 0;
438
+ const repelDir = t < mouseY ? -1 : 1;
439
+ const w1 = Math.sin(px * 4 + voidT * 0.9 + li * 0.20) * 0.030;
440
+ const w2 = Math.sin(px * 9 - voidT * 0.6 + li * 0.28) * 0.016;
441
+ const w3 = Math.sin(px * 2.5 + voidT * 0.35 + li * 0.10) * 0.050;
442
+ const w4 = Math.sin(px * 16 + voidT * 1.5 + li * 0.50) * 0.007;
443
+ const baseY = t + 0.02;
444
+ const y = (baseY + w1 + w2 + w3 + w4 + repel * repelDir * 0.06) * H;
445
+ if (si === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
446
+ }
447
+ ctx.stroke();
448
+ }
449
+ animFrame = requestAnimationFrame(drawVoid);
450
+ }
451
+
452
+ function drawFern() {
453
+ const W = canvas.width, H = canvas.height;
454
+ ctx.clearRect(0, 0, W, H);
455
+ ctx.fillStyle = "#000000";
456
+ ctx.fillRect(0, 0, W, H);
457
+ const now = Date.now() * 0.001;
458
+ for (const s of fernStars) {
459
+ const twinkle = 0.6 + 0.4 * Math.sin(now * 1.2 + s.twinkleOffset);
460
+ ctx.beginPath();
461
+ ctx.arc(s.x * W, s.y * H, s.r, 0, Math.PI * 2);
462
+ ctx.fillStyle = `rgba(255,255,255,${s.opacity * twinkle})`;
463
+ ctx.fill();
464
+ }
465
+ const mx = mouseX * W, my = mouseY * H;
466
+ for (const n of fernNodes) {
467
+ const dx = n.x - mx, dy = n.y - my;
468
+ const dist = Math.sqrt(dx * dx + dy * dy);
469
+ if (dist < 100 && dist > 0) {
470
+ const force = (100 - dist) / 100 * 0.4;
471
+ n.vx += (dx / dist) * force;
472
+ n.vy += (dy / dist) * force;
473
+ }
474
+ const speed = Math.sqrt(n.vx * n.vx + n.vy * n.vy);
475
+ if (speed > 1.2) { n.vx = (n.vx / speed) * 1.2; n.vy = (n.vy / speed) * 1.2; }
476
+ n.x += n.vx; n.y += n.vy;
477
+ if (n.x < 0) n.x = W; if (n.x > W) n.x = 0;
478
+ if (n.y < 0) n.y = H; if (n.y > H) n.y = 0;
479
+ }
480
+ for (let i = 0; i < fernNodes.length; i++) {
481
+ for (let j = i + 1; j < fernNodes.length; j++) {
482
+ const dx = fernNodes[i].x - fernNodes[j].x;
483
+ const dy = fernNodes[i].y - fernNodes[j].y;
484
+ const dist = Math.sqrt(dx * dx + dy * dy);
485
+ if (dist < 160) {
486
+ ctx.beginPath();
487
+ ctx.strokeStyle = `rgba(255,255,255,${(1 - dist / 160) * 0.18})`;
488
+ ctx.lineWidth = 0.5;
489
+ ctx.moveTo(fernNodes[i].x, fernNodes[i].y);
490
+ ctx.lineTo(fernNodes[j].x, fernNodes[j].y);
491
+ ctx.stroke();
492
+ }
493
+ }
494
+ }
495
+ for (const n of fernNodes) {
496
+ ctx.beginPath();
497
+ ctx.arc(n.x, n.y, n.r, 0, Math.PI * 2);
498
+ ctx.fillStyle = "rgba(255,255,255,0.5)";
499
+ ctx.fill();
500
+ }
501
+ fernShootingTimer++;
502
+ if (fernShootingTimer > 180 + Math.random() * 240) {
503
+ spawnShootingStar();
504
+ fernShootingTimer = 0;
505
+ }
506
+ shootingStars = shootingStars.filter(s => s.life > 0);
507
+ for (const s of shootingStars) {
508
+ const tx = s.x + Math.cos(s.angle) * s.len;
509
+ const ty = s.y + Math.sin(s.angle) * s.len;
510
+ const grad = ctx.createLinearGradient(s.x, s.y, tx, ty);
511
+ grad.addColorStop(0, `rgba(255,255,255,0)`);
512
+ grad.addColorStop(0.3, `rgba(255,255,255,${s.life * 0.6})`);
513
+ grad.addColorStop(1, `rgba(255,255,255,${s.life})`);
514
+ ctx.beginPath();
515
+ ctx.strokeStyle = grad;
516
+ ctx.lineWidth = 1.5;
517
+ ctx.moveTo(s.x, s.y);
518
+ ctx.lineTo(tx, ty);
519
+ ctx.stroke();
520
+ s.x += Math.cos(s.angle) * s.speed;
521
+ s.y += Math.sin(s.angle) * s.speed;
522
+ s.life -= s.decay;
523
+ }
524
+ animFrame = requestAnimationFrame(drawFern);
525
+ }
526
+
527
+ function stopAnim() {
528
+ if (animFrame) { cancelAnimationFrame(animFrame); animFrame = null; }
529
+ }
530
+
531
+ function applyTheme(theme) {
532
+ stopAnim();
533
+ document.body.classList.remove("theme-nexora", "theme-wave", "theme-void", "theme-fern");
534
+ currentTheme = theme;
535
+ localStorage.setItem("theme", theme);
536
+ document.querySelectorAll(".theme-option").forEach(o => {
537
+ o.classList.toggle("selected", o.dataset.theme === theme);
538
+ });
539
+ if (theme === "nexora") {
540
+ document.body.classList.add("theme-nexora");
541
+ stars.forEach(s => s.offset = Math.random() * Math.PI * 2);
542
+ drawNexora();
543
+ } else if (theme === "wave") {
544
+ document.body.classList.add("theme-wave");
545
+ drawWave();
546
+ } else if (theme === "void") {
547
+ document.body.classList.add("theme-void");
548
+ drawVoid();
549
+ } else if (theme === "fern") {
550
+ document.body.classList.add("theme-fern");
551
+ shootingStars = [];
552
+ fernShootingTimer = 0;
553
+ drawFern();
554
+ }
555
+ updateQuickAppColors();
556
+ }
557
+
558
+ function updateQuickAppColors() {
559
+ const color = getComputedStyle(document.documentElement).getPropertyValue("--green").trim() || "#4ab464";
560
+ document.querySelectorAll(".quick-app-icon svg path, .quick-app-icon svg polygon").forEach(el => {
561
+ if (el.getAttribute("fill") && el.getAttribute("fill") !== "none") el.setAttribute("fill", color);
562
+ });
563
+ }
564
+
565
+ document.getElementById("theme-options").addEventListener("click", function(e) {
566
+ const opt = e.target.closest(".theme-option");
567
+ if (!opt) return;
568
+ applyTheme(opt.dataset.theme);
569
+ });
570
+
571
+ /* ══════════════════════════════════════════
572
+ CLOAK
573
+ ══════════════════════════════════════════ */
574
+ let currentCloak = { title: "Index", favicon: "", cloak: "none" };
575
+
576
+ function applyCloak(title, favicon) {
577
+ document.title = title;
578
+ let link = document.querySelector("link[rel~='icon']");
579
+ if (!link) { link = document.createElement("link"); link.rel = "icon"; document.head.appendChild(link); }
580
+ link.href = favicon || "data:,";
581
+ }
582
+
583
+ document.getElementById("cloak-options").addEventListener("click", function(e) {
584
+ const opt = e.target.closest(".cloak-option");
585
+ if (!opt) return;
586
+ document.querySelectorAll(".cloak-option").forEach(o => o.classList.remove("selected"));
587
+ opt.classList.add("selected");
588
+ currentCloak = { title: opt.dataset.title, favicon: opt.dataset.favicon, cloak: opt.dataset.cloak };
589
+ applyCloak(currentCloak.title, currentCloak.favicon);
590
+ localStorage.setItem("cloak", JSON.stringify(currentCloak));
591
+ });
592
+
593
+ /* ══════════════════════════════════════════
594
+ ABOUT:BLANK
595
+ ══════════════════════════════════════════ */
596
+ document.getElementById("ab-btn").addEventListener("click", function() {
597
+ const entry = tabs.get(activeId);
598
+ let url = null;
599
+ if (entry && entry.frame) {
600
+ try { url = entry.frame.frame.contentWindow.location.href; } catch(_) {}
601
+ }
602
+ if (!url || url === "about:blank") {
603
+ url = prompt("Enter a URL to open in about:blank:");
604
+ if (!url) return;
605
+ if (!/^https?:\/\//i.test(url)) url = "https://" + url;
606
+ }
607
+ openAboutBlank(url);
608
+ });
609
+
610
+ function openAboutBlank(url) {
611
+ const win = window.open("about:blank", "_blank");
612
+ if (!win) { alert("Allow popups for about:blank to work."); return; }
613
+ const baseDir = new URL("./", location.href).pathname;
614
+ const workerPath = new URL("baremux/worker.js", location.href).pathname;
615
+ const swScriptPath = new URL("register-sw.js", location.href).pathname;
616
+ const scramjetPrefix = baseDir + "service/";
617
+ win.document.open();
618
+ win.document.write(`<!doctype html><html><head>
619
+ <script src="https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js"><\/script>
620
+ <script src="https://unpkg.com/@mercuryworkshop/bare-mux@2.1.7/dist/index.js"><\/script>
621
+ <script src="${swScriptPath}"><\/script>
622
+ <style>*{margin:0;padding:0;}iframe{width:100vw;height:100vh;border:none;}<\/style>
623
+ </head><body><script>
624
+ (async()=>{
625
+ const {ScramjetController}=$scramjetLoadController();
626
+ const sj=new ScramjetController({prefix:"${scramjetPrefix}",files:{wasm:"https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.wasm.wasm",all:"https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js",sync:"https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js"}});
627
+ sj.init();
628
+ await registerSW();
629
+ const c=new BareMux.BareMuxConnection("${workerPath}");
630
+ const wispUrl=(location.host && location.host.includes("unpkg.com")) ? "wss://wisp.mercurywork.shop/" : ((location.protocol==="https:"?"wss":"ws")+"://"+location.host+"/wisp/");
631
+ const transportUrl="https://unpkg.com/@mercuryworkshop/libcurl-transport@1.5.2/dist/index.mjs";
632
+ if((await c.getTransport())!==transportUrl)await c.setTransport(transportUrl,[{websocket:wispUrl}]);
633
+ const f=sj.createFrame();
634
+ document.body.appendChild(f.frame);
635
+ f.go("${url}");
636
+ })();
637
+ <\/script></body></html>`);
638
+ win.document.close();
639
+ }
640
+
641
+ /* ══════════════════════════════════════════
642
+ DRAWER NAVIGATION
643
+ ══════════════════════════════════════════ */
644
+ const overlay = document.getElementById("settings-overlay");
645
+ const fab = document.getElementById("settings-fab");
646
+ const drawerBack = document.getElementById("drawer-back");
647
+ const drawerTitle= document.getElementById("drawer-title");
648
+ const drawerClose= document.getElementById("drawer-close");
649
+
650
+ const PAGE_TITLES = {
651
+ "dpage-main": "// settings",
652
+ "dpage-appearance": "// appearance",
653
+ "dpage-cloak": "// tab cloak",
654
+ "dpage-privacy": "// privacy",
655
+ "dpage-about": "// about",
656
+ };
657
+
658
+ let pageHistory = ["dpage-main"];
659
+
660
+ function showPage(pageId) {
661
+ document.querySelectorAll(".drawer-page").forEach(p => p.classList.remove("active"));
662
+ document.getElementById(pageId).classList.add("active");
663
+ drawerTitle.textContent = PAGE_TITLES[pageId] || "// settings";
664
+ drawerBack.style.display = pageHistory.length > 1 ? "inline-flex" : "none";
665
+ }
666
+
667
+ function gotoPage(pageId) {
668
+ pageHistory.push(pageId);
669
+ showPage(pageId);
670
+ }
671
+
672
+ drawerBack.addEventListener("click", () => {
673
+ if (pageHistory.length <= 1) return;
674
+ pageHistory.pop();
675
+ showPage(pageHistory[pageHistory.length - 1]);
676
+ });
677
+
678
+ document.querySelectorAll(".settings-nav-item[data-goto]").forEach(item => {
679
+ item.addEventListener("click", () => gotoPage(item.dataset.goto));
680
+ });
681
+
682
+ fab.addEventListener("click", () => {
683
+ const open = overlay.classList.toggle("open");
684
+ fab.classList.toggle("active", open);
685
+ if (open) {
686
+ pageHistory = ["dpage-main"];
687
+ showPage("dpage-main");
688
+ }
689
+ });
690
+
691
+ overlay.addEventListener("click", e => {
692
+ if (e.target === overlay) {
693
+ overlay.classList.remove("open");
694
+ fab.classList.remove("active");
695
+ }
696
+ });
697
+
698
+ drawerClose.addEventListener("click", () => {
699
+ overlay.classList.remove("open");
700
+ fab.classList.remove("active");
701
+ });
702
+
703
+ /* ══════════════════════════════════════════
704
+ RESTORE SETTINGS
705
+ ══════════════════════════════════════════ */
706
+ (function restoreSettings() {
707
+ const savedCloak = localStorage.getItem("cloak");
708
+ if (savedCloak) {
709
+ try {
710
+ const c = JSON.parse(savedCloak);
711
+ currentCloak = c;
712
+ applyCloak(c.title, c.favicon);
713
+ document.querySelectorAll(".cloak-option").forEach(o => {
714
+ o.classList.toggle("selected", o.dataset.cloak === c.cloak);
715
+ });
716
+ } catch(_) {}
717
+ }
718
+ const savedTheme = localStorage.getItem("theme") || "default";
719
+ applyTheme(savedTheme);
720
+ })();
721
+
722
+ /* ══════════════════════════════════════════
723
+ QUICK APPS / APPS REGISTRY (unchanged)
724
+ ══════════════════════════════════════════ */
725
+ const QUICK_APPS = [
726
+ { name: "duckduckgo", url: "https://www.duckduckgo.com", icon: `<img src="icons/DDG-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
727
+ { name: "youtube", url: "https://www.youtube.com", icon: `<img src="icons/YT-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
728
+ { name: "tiktok", url: "https://www.tiktok.com", icon: `<img src="icons/TT-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
729
+ { name: "discord", url: "https://www.discord.com", icon: `<img src="icons/DC-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
730
+ { name: "Cool Math Games", url: "https://www.coolmathgames.com", icon: `<img src="icons/CMG-Favicon.jpg" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
731
+ { name: "x [twitter]", url: "https://www.x.com", icon: `<img src="icons/X-Favicon.jpg" width="25" height="24" style="border-radius:2px;object-fit:contain;" />` },
732
+ { name: "chatgpt", url: "https://chat.openai.com", icon: `<img src="icons/CGPT-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
733
+ { name: "music", url: "https://freefy.app/", icon: `<img src="icons/MCTF-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
734
+ { name: "movies", url: "https://www.justwatch.com/ca/provider/free-all/", icon: `<img src="icons/MP4-Favicon.webp" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
735
+ ];
736
+
737
+ const APPS_REGISTRY = [
738
+ { name: "Google", url: "https://www.google.com", icon: `<img src="icons/G-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Search the web", tags: ["search","google"] },
739
+ { name: "YouTube", url: "https://www.youtube.com", icon: `<img src="icons/YT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Watch videos", tags: ["video","media"] },
740
+ { name: "Discord", url: "https://discord.com/app", icon: `<img src="icons/DC-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Chat with friends", tags: ["social","chat"] },
741
+ { name: "Spotify", url: "https://open.spotify.com", icon: `<img src="icons/S-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Stream music", tags: ["music","media"] },
742
+ { name: "Monochrome.tf", url: "https://monochrome.tf", icon: `<img src="icons/MCTF-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Stream music", tags: ["music","media"] },
743
+ { name: "Reddit", url: "https://www.reddit.com", icon: `<img src="icons/RDT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Browse communities", tags: ["social","news"] },
744
+ { name: "X / Twitter", url: "https://www.x.com", icon: `<img src="icons/X-Favicon.jpg" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Trending topics & posts", tags: ["social","news"] },
745
+ { name: "TikTok", url: "https://www.tiktok.com", icon: `<img src="icons/TT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Short-form videos", tags: ["video","social"] },
746
+ { name: "ChatGPT", url: "https://chat.openai.com", icon: `<img src="icons/CGPT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "AI assistant by OpenAI", tags: ["ai","tools"] },
747
+ { name: "Now.gg", url: "https://www.now.gg/", icon: `<img src="icons/NGG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Online games for all.", tags: ["games","dev"] },
748
+ { name: "Crazy Games", url: "https://www.crazygames.com/", icon: `<img src="icons/CZG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Online games for all.", tags: ["games","dev"] },
749
+ { name: "Gmail", url: "https://mail.google.com", icon: `<img src="https://ssl.gstatic.com/ui/v1/icons/mail/rfr/gmail.ico" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Email by Google", tags: ["productivity","google"] },
750
+ { name: "DuckDuckGo", url: "https://www.duckduckgo.com", icon: `<img src="icons/DDG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Private search", tags: ["search"] },
751
+ { name: "Bing", url: "https://www.bing.com", icon: `<img src="icons/BNG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Microsoft search", tags: ["search"] },
752
+ { name: "GitHub", url: "https://github.com", icon: `<img src="icons/GH-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Code & collaboration", tags: ["tools","dev"] },
753
+ { name: "Replit", url: "https://replit.com", icon: `<img src="icons/RPT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Code in the browser", tags: ["tools","dev"] },
754
+ { name: "Neal.fun", url: "https://www.neal.fun", icon: `<img src="icons/NDF-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Many fun games.", tags: ["games","education"] },
755
+ { name: "Cool Math Games", url: "https://www.coolmathgames.com", icon: `<img src="icons/CMG-Favicon.jpg" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Math-based browser games", tags: ["games","education"] },
756
+ ];
757
+
758
+ const cfg = (typeof window !== "undefined" && window.__INDEX_CONFIG) || {};
759
+ const scramjetFiles = cfg.scramjet || {
760
+ wasm: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.wasm.wasm",
761
+ all: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js",
762
+ sync: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js"
763
+ };
764
+ const baseDir = new URL("./", location.href).pathname;
765
+ const workerPath = (cfg.baremux && cfg.baremux.worker) || new URL("baremux/worker.js", location.href).pathname;
766
+ const scramjetPrefix = baseDir + "service/";
767
+
768
+ const { ScramjetController } = $scramjetLoadController();
769
+ const scramjet = new ScramjetController({
770
+ files: scramjetFiles,
771
+ prefix: scramjetPrefix
772
+ });
773
+ scramjet.init();
774
+
775
+ const connection = new BareMux.BareMuxConnection(workerPath);
776
+ let transportReady = false;
777
+
778
+ async function ensureTransport() {
779
+ if (transportReady) return;
780
+ await registerSW();
781
+ const wispUrl = cfg.wispUrl || (location.host && location.host.includes("unpkg.com") ? "wss://wisp.mercurywork.shop/" : ((location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/"));
782
+ const transportUrl = (cfg.libcurl && cfg.libcurl.transport) || "https://unpkg.com/@mercuryworkshop/libcurl-transport@1.5.2/dist/index.mjs";
783
+ if ((await connection.getTransport()) !== transportUrl) {
784
+ await connection.setTransport(transportUrl, [{ websocket: wispUrl }]);
785
+ }
786
+ transportReady = true;
787
+ }
788
+
789
+ /* ══════════════════════════════════════════
790
+ TAB ENGINE (unchanged)
791
+ ══════════════════════════════════════════ */
792
+ const tabBar = document.getElementById("tab-bar");
793
+ const newTabBtn = document.getElementById("new-tab-btn");
794
+ const tabContent = document.getElementById("tab-content");
795
+
796
+ let tabCounter = 0, activeId = null;
797
+ const tabs = new Map();
798
+
799
+ function truncate(s, n) { return s.length > n ? s.slice(0, n) + "\u2026" : s; }
800
+ function setTabTitle(id, title) {
801
+ const e = tabs.get(id); if (!e) return;
802
+ e.tabEl.querySelector(".tab-title").textContent = truncate(title || "new tab", 22);
803
+ }
804
+ function setTabLoading(id, loading) { tabs.get(id)?.tabEl.classList.toggle("loading", loading); }
805
+
806
+ function createTab(title) {
807
+ if (tabs.size >= 20) return;
808
+ const id = ++tabCounter;
809
+ const tabEl = document.createElement("div");
810
+ tabEl.className = "tab"; tabEl.dataset.id = id;
811
+ tabEl.innerHTML =
812
+ '<div class="tab-spinner"></div>' +
813
+ '<span class="tab-title">' + truncate(title || "new tab", 22) + '</span>' +
814
+ '<button class="tab-close" title="Close tab">\u2715</button>';
815
+ const paneEl = document.createElement("div");
816
+ paneEl.className = "tab-pane"; paneEl.dataset.id = id;
817
+ paneEl.innerHTML = getHomeHTML(id);
818
+ tabBar.insertBefore(tabEl, newTabBtn);
819
+ tabContent.appendChild(paneEl);
820
+ tabs.set(id, { tabEl, paneEl, frame: null });
821
+ wireHome(paneEl, id);
822
+ tabEl.addEventListener("click", e => { if (!e.target.classList.contains("tab-close")) activateTab(id); });
823
+ tabEl.querySelector(".tab-close").addEventListener("click", e => { e.stopPropagation(); closeTab(id); });
824
+ activateTab(id);
825
+ return id;
826
+ }
827
+
828
+ function activateTab(id) {
829
+ activeId = id;
830
+ tabs.forEach(({ tabEl, paneEl }, tid) => {
831
+ tabEl.classList.toggle("active", tid === id);
832
+ paneEl.classList.toggle("active", tid === id);
833
+ });
834
+ }
835
+
836
+ function closeTab(id) {
837
+ if (tabs.size === 1) return;
838
+ const entry = tabs.get(id); if (!entry) return;
839
+ const keys = [...tabs.keys()], idx = keys.indexOf(id);
840
+ entry.tabEl.remove(); entry.paneEl.remove(); tabs.delete(id);
841
+ if (activeId === id) {
842
+ const r = [...tabs.keys()];
843
+ activateTab(r[Math.min(idx, r.length - 1)]);
844
+ }
845
+ }
846
+
847
+ async function navigateTab(id, url) {
848
+ const entry = tabs.get(id); if (!entry) return;
849
+ setTabLoading(id, true); setTabTitle(id, url);
850
+ try { await ensureTransport(); }
851
+ catch (err) {
852
+ setTabLoading(id, false); setTabTitle(id, "error");
853
+ entry.paneEl.innerHTML = '<div class="home-content"><div class="home-center"><p class="sj-error">failed to register service worker.</p><pre style="color:var(--text-dim);font-size:11px;">' + err.toString() + '</pre></div></div>';
854
+ return;
855
+ }
856
+ entry.paneEl.innerHTML = "";
857
+ if (!entry.frame) entry.frame = scramjet.createFrame();
858
+ entry.paneEl.appendChild(entry.frame.frame);
859
+ entry.frame.go(url);
860
+ entry.frame.frame.addEventListener("load", function() {
861
+ setTabLoading(id, false);
862
+ try { const t = entry.frame.frame.contentDocument?.title; if (t) setTabTitle(id, t); } catch(_) {}
863
+ }, { once: true });
864
+ let attempts = 0;
865
+ const poll = setInterval(() => {
866
+ attempts++;
867
+ try { const t = entry.frame.frame.contentDocument?.title; if (t) { setTabTitle(id, t); setTabLoading(id, false); clearInterval(poll); } } catch(_) {}
868
+ if (attempts > 80) { setTabLoading(id, false); clearInterval(poll); }
869
+ }, 100);
870
+ }
871
+
872
+ function buildQuickAppsHTML() {
873
+ let html = '<div class="quick-apps"><div class="quick-apps-label">quick apps</div><div class="quick-apps-grid">';
874
+ for (const app of QUICK_APPS) {
875
+ html += '<div class="quick-app" data-url="' + app.url + '"><div class="quick-app-icon">' + app.icon + '</div><span class="quick-app-name">' + app.name + '</span></div>';
876
+ }
877
+ return html + '</div></div>';
878
+ }
879
+
880
+ function getHomeHTML(id) {
881
+ return '<div class="home-content">' +
882
+ '<div class="home-center">' +
883
+ '<div class="index-title"><span class="tw-text"></span><span class="index-cursor"></span></div>' +
884
+ '<div class="index-sub tw-sub"> </div>' +
885
+ '<form class="sj-form" data-tab="' + id + '" style="width:100%;max-width:560px;display:flex;flex-direction:column;align-items:center;">' +
886
+ '<input class="sj-search-engine" value="https://duckduckgo.com/?q=%s" type="hidden" />' +
887
+ '<div class="search-row">' +
888
+ '<span class="search-prompt">&#62;_</span>' +
889
+ '<input class="sj-address" type="text" placeholder="search or enter a url" autocomplete="off" spellcheck="false" />' +
890
+ '<span class="search-enter">enter &crarr;</span>' +
891
+ '</div><p class="sj-error"></p></form>' +
892
+ buildQuickAppsHTML() +
893
+ '</div>' +
894
+ '</div>';
895
+ }
896
+
897
+ function wireHome(paneEl, id) {
898
+ const form = paneEl.querySelector(".sj-form");
899
+ if (form) {
900
+ form.addEventListener("submit", async e => {
901
+ e.preventDefault();
902
+ const val = (form.querySelector(".sj-address").value || "").trim();
903
+ if (!val) return;
904
+ const engine = form.querySelector(".sj-search-engine").value || "https://www.google.com/search?q=%s";
905
+ await navigateTab(id, search(val, engine));
906
+ });
907
+ }
908
+ paneEl.querySelectorAll(".quick-app").forEach(el => {
909
+ el.addEventListener("click", () => navigateTab(id, el.dataset.url));
910
+ });
911
+
912
+ const twEl = paneEl.querySelector(".tw-text");
913
+ const twSub = paneEl.querySelector(".tw-sub");
914
+ if (!twEl) return;
915
+ const word = "Index";
916
+ const fonts = [
917
+ "'Courier New', monospace","'Georgia', serif","'Impact', sans-serif",
918
+ "'Palatino Linotype', serif","'Lucida Console', monospace",
919
+ "'Trebuchet MS', sans-serif","'Garamond', serif","'Arial Narrow', sans-serif",
920
+ ];
921
+ let fontIndex = 0;
922
+
923
+ function runCycle() {
924
+ const titleEl = paneEl.querySelector(".index-title");
925
+ if (titleEl) titleEl.style.fontFamily = fonts[fontIndex % fonts.length];
926
+ fontIndex++;
927
+ if (twSub) twSub.classList.remove("visible");
928
+ let i = 0;
929
+ function type() {
930
+ twEl.textContent = word.slice(0, i);
931
+ if (i < word.length) { i++; setTimeout(type, 80 + Math.random() * 70); }
932
+ else { if (twSub) twSub.classList.add("visible"); setTimeout(deleteText, 2200); }
933
+ }
934
+ let j = word.length;
935
+ function deleteText() {
936
+ if (twSub) twSub.classList.remove("visible");
937
+ twEl.textContent = word.slice(0, j);
938
+ if (j > 0) { j--; setTimeout(deleteText, 55 + Math.random() * 40); }
939
+ else { setTimeout(runCycle, 400); }
940
+ }
941
+ setTimeout(type, 400);
942
+ }
943
+ runCycle();
944
+ }
945
+
946
+ newTabBtn.addEventListener("click", () => createTab());
947
+ createTab();
948
+
949
+ /* ══════════════════════════════════════════
950
+ GAMES TAB (unchanged)
951
+ ══════════════════════════════════════════ */
952
+ const gamesBtn = document.getElementById("games-btn");
953
+ let gamesTabId = null;
954
+ let gamesRegistry = [];
955
+
956
+ async function loadGamesRegistry() {
957
+ try {
958
+ const res = await fetch("games/games.json");
959
+ if (!res.ok) throw new Error();
960
+ gamesRegistry = await res.json();
961
+ } catch(_) { gamesRegistry = []; }
962
+ }
963
+
964
+ function getAllTags(registry) {
965
+ const set = new Set();
966
+ for (const g of registry) (g.tags || []).forEach(t => set.add(t.toLowerCase()));
967
+ return [...set].sort();
968
+ }
969
+
970
+ function buildGamesPage(tabId) {
971
+ const entry = tabs.get(tabId); if (!entry) return;
972
+ const allTags = getAllTags(gamesRegistry);
973
+ const total = gamesRegistry.length;
974
+ const tagPills = ['<button class="games-tag active" data-tag="all">all</button>',
975
+ ...allTags.map(t => `<button class="games-tag" data-tag="${t}">${t}</button>`)
976
+ ].join("");
977
+ entry.paneEl.innerHTML = `
978
+ <div class="games-content">
979
+ <div class="games-topbar">
980
+ <span class="games-topbar-title">// games</span>
981
+ <div class="games-search-wrap">
982
+ <span class="games-search-icon">⌕</span>
983
+ <input class="games-search" id="games-search-input" type="text" placeholder="search ${total} games…" autocomplete="off" spellcheck="false" />
984
+ <button class="games-search-clear" id="games-search-clear" title="clear">✕</button>
985
+ </div>
986
+ <span class="games-count-badge" id="games-count-badge">${total} games</span>
987
+ <button class="games-close-btn" id="games-close-btn">✕ close</button>
988
+ </div>
989
+ ${allTags.length > 0 ? `<div class="games-tagbar" id="games-tagbar">${tagPills}</div>` : ""}
990
+ <div class="games-grid-area"><div class="games-grid" id="games-grid"></div></div>
991
+ </div>`;
992
+ renderCards(entry.paneEl, gamesRegistry);
993
+ const searchInput = entry.paneEl.querySelector("#games-search-input");
994
+ const searchClear = entry.paneEl.querySelector("#games-search-clear");
995
+ let activeTag = "all";
996
+ function applyFilters() {
997
+ const q = searchInput.value.trim().toLowerCase();
998
+ searchClear.classList.toggle("visible", q.length > 0);
999
+ const filtered = gamesRegistry.filter(g => {
1000
+ const matchTag = activeTag === "all" || (g.tags||[]).map(t=>t.toLowerCase()).includes(activeTag);
1001
+ const matchQ = !q || g.name.toLowerCase().includes(q) || (g.description||"").toLowerCase().includes(q) || (g.tags||[]).some(t=>t.toLowerCase().includes(q));
1002
+ return matchTag && matchQ;
1003
+ });
1004
+ renderCards(entry.paneEl, filtered);
1005
+ entry.paneEl.querySelector("#games-count-badge").textContent = filtered.length === total ? `${total} games` : `${filtered.length} / ${total}`;
1006
+ }
1007
+ searchInput.addEventListener("input", applyFilters);
1008
+ searchClear.addEventListener("click", () => { searchInput.value=""; applyFilters(); searchInput.focus(); });
1009
+ const tagbar = entry.paneEl.querySelector("#games-tagbar");
1010
+ if (tagbar) {
1011
+ tagbar.addEventListener("click", e => {
1012
+ const btn = e.target.closest(".games-tag"); if (!btn) return;
1013
+ activeTag = btn.dataset.tag;
1014
+ tagbar.querySelectorAll(".games-tag").forEach(b => b.classList.toggle("active", b===btn));
1015
+ applyFilters();
1016
+ });
1017
+ }
1018
+ entry.paneEl.querySelector("#games-close-btn").addEventListener("click", () => { closeTab(tabId); gamesTabId=null; });
1019
+ }
1020
+
1021
+ function renderCards(paneEl, list) {
1022
+ const grid = paneEl.querySelector("#games-grid"); if (!grid) return;
1023
+ if (list.length === 0) { grid.innerHTML = '<div class="games-noresults">no games match your search.<br><span style="opacity:0.5">try a different keyword or tag</span></div>'; return; }
1024
+ grid.innerHTML = list.map(g => {
1025
+ const tagsHTML = (g.tags||[]).length ? `<div class="game-card-tags">${(g.tags).map(t=>`<span class="game-card-tag">${t}</span>`).join("")}</div>` : "";
1026
+ const iconSrc = g.icon && g.icon.startsWith("/") ? g.icon.replace(/^\/+/, '') : g.icon;
1027
+ const iconHTML = (iconSrc && (iconSrc.includes("/") || iconSrc.includes(".")))
1028
+ ? `<img src="${iconSrc}" style="width:2em;height:2em;object-fit:contain;border-radius:4px;" onerror="this.outerHTML='🎮'" />`
1029
+ : (iconSrc || "🎮");
1030
+ return `<div class="game-card" data-file="${g.file}" data-name="${g.name}"><div class="game-card-icon">${iconHTML}</div><div class="game-card-name">${g.name}</div>${g.description?`<div class="game-card-desc">${g.description}</div>`:""}${tagsHTML}</div>`;
1031
+ }).join("");
1032
+ grid.querySelectorAll(".game-card").forEach(card => { card.addEventListener("click", () => openGameModal(card.dataset.file, card.dataset.name)); });
1033
+ }
1034
+ const gameModal = document.getElementById("game-modal");
1035
+ const gmName = document.getElementById("gm-name");
1036
+ const gmFile = document.getElementById("gm-file");
1037
+ const gmIframe = document.getElementById("gm-iframe");
1038
+ const gmClose = document.getElementById("gm-close");
1039
+ const gmFullscreen = document.getElementById("gm-fullscreen");
1040
+
1041
+ function openGameModal(file, name) {
1042
+ if (file === "gamesuggestions.html") {
1043
+ window.open("https://forms.gle/aSBH2kMVEUwmhiRp6", "_blank");
1044
+ return;
1045
+ }
1046
+ gmName.textContent = name; gmFile.textContent = file;
1047
+ gmIframe.src = "games/" + file;
1048
+ gameModal.classList.add("open");
1049
+ }
1050
+ function closeGameModal() { gameModal.classList.remove("open"); gmIframe.src="about:blank"; }
1051
+ gmClose.addEventListener("click", closeGameModal);
1052
+ document.addEventListener("keydown", e => { if (e.key==="Escape" && gameModal.classList.contains("open")) closeGameModal(); });
1053
+ gmFullscreen.addEventListener("click", () => {
1054
+ if (gmIframe.requestFullscreen) gmIframe.requestFullscreen();
1055
+ else if (gmIframe.webkitRequestFullscreen) gmIframe.webkitRequestFullscreen();
1056
+ });
1057
+
1058
+ async function openGamesTab() {
1059
+ if (gamesTabId && tabs.has(gamesTabId)) { activateTab(gamesTabId); gamesBtn.classList.add("active"); return; }
1060
+ await loadGamesRegistry();
1061
+ gamesTabId = createTab("🎮 games");
1062
+ setTabTitle(gamesTabId, "🎮 games");
1063
+ buildGamesPage(gamesTabId);
1064
+ gamesBtn.classList.add("active");
1065
+ }
1066
+ gamesBtn.addEventListener("click", openGamesTab);
1067
+
1068
+ /* ══════════════════════════════════════════
1069
+ APPS TAB (unchanged)
1070
+ ══════════════════════════════════════════ */
1071
+ const appsBtn = document.getElementById("apps-btn");
1072
+ let appsTabId = null;
1073
+
1074
+ function getAllAppTags(registry) {
1075
+ const set = new Set();
1076
+ for (const a of registry) (a.tags||[]).forEach(t => set.add(t.toLowerCase()));
1077
+ return [...set].sort();
1078
+ }
1079
+
1080
+ function buildAppsPage(tabId) {
1081
+ const entry = tabs.get(tabId); if (!entry) return;
1082
+ const allTags = getAllAppTags(APPS_REGISTRY);
1083
+ const total = APPS_REGISTRY.length;
1084
+ const tagPills = ['<button class="games-tag active" data-tag="all">all</button>',
1085
+ ...allTags.map(t => `<button class="games-tag" data-tag="${t}">${t}</button>`)
1086
+ ].join("");
1087
+ entry.paneEl.innerHTML = `
1088
+ <div class="games-content">
1089
+ <div class="games-topbar">
1090
+ <span class="games-topbar-title">// apps</span>
1091
+ <div class="games-search-wrap">
1092
+ <span class="games-search-icon">⌕</span>
1093
+ <input class="games-search" id="apps-search-input" type="text" placeholder="search ${total} apps…" autocomplete="off" spellcheck="false" />
1094
+ <button class="games-search-clear" id="apps-search-clear" title="clear">✕</button>
1095
+ </div>
1096
+ <span class="games-count-badge" id="apps-count-badge">${total} apps</span>
1097
+ <button class="games-close-btn" id="apps-close-btn">✕ close</button>
1098
+ </div>
1099
+ <div class="games-tagbar" id="apps-tagbar">${tagPills}</div>
1100
+ <div class="games-grid-area"><div class="games-grid" id="apps-grid"></div></div>
1101
+ </div>`;
1102
+ renderAppCards(entry.paneEl, APPS_REGISTRY, tabId);
1103
+ const searchInput = entry.paneEl.querySelector("#apps-search-input");
1104
+ const searchClear = entry.paneEl.querySelector("#apps-search-clear");
1105
+ let activeTag = "all";
1106
+ function applyFilters() {
1107
+ const q = searchInput.value.trim().toLowerCase();
1108
+ searchClear.classList.toggle("visible", q.length > 0);
1109
+ const filtered = APPS_REGISTRY.filter(a => {
1110
+ const matchTag = activeTag === "all" || (a.tags||[]).map(t=>t.toLowerCase()).includes(activeTag);
1111
+ const matchQ = !q || a.name.toLowerCase().includes(q) || (a.description||"").toLowerCase().includes(q) || (a.tags||[]).some(t=>t.toLowerCase().includes(q));
1112
+ return matchTag && matchQ;
1113
+ });
1114
+ renderAppCards(entry.paneEl, filtered, tabId);
1115
+ entry.paneEl.querySelector("#apps-count-badge").textContent = filtered.length===total ? `${total} apps` : `${filtered.length} / ${total}`;
1116
+ }
1117
+ searchInput.addEventListener("input", applyFilters);
1118
+ searchClear.addEventListener("click", () => { searchInput.value=""; applyFilters(); searchInput.focus(); });
1119
+ const tagbar = entry.paneEl.querySelector("#apps-tagbar");
1120
+ if (tagbar) {
1121
+ tagbar.addEventListener("click", e => {
1122
+ const btn = e.target.closest(".games-tag"); if (!btn) return;
1123
+ activeTag = btn.dataset.tag;
1124
+ tagbar.querySelectorAll(".games-tag").forEach(b => b.classList.toggle("active", b===btn));
1125
+ applyFilters();
1126
+ });
1127
+ }
1128
+ entry.paneEl.querySelector("#apps-close-btn").addEventListener("click", () => { closeTab(tabId); appsTabId=null; appsBtn.classList.remove("active"); });
1129
+ }
1130
+
1131
+ function renderAppCards(paneEl, list, tabId) {
1132
+ const grid = paneEl.querySelector("#apps-grid"); if (!grid) return;
1133
+ if (list.length===0) { grid.innerHTML='<div class="games-noresults">no apps match your search.<br><span style="opacity:0.5">try a different keyword or tag</span></div>'; return; }
1134
+ grid.innerHTML = list.map(a => {
1135
+ const tagsHTML = (a.tags||[]).length ? `<div class="game-card-tags">${(a.tags).map(t=>`<span class="game-card-tag">${t}</span>`).join("")}</div>` : "";
1136
+ return `<div class="app-card game-card" data-url="${a.url}" data-name="${a.name}"><div class="game-card-icon app-card-icon">${a.icon}</div><div class="game-card-name">${a.name}</div>${a.description?`<div class="game-card-desc">${a.description}</div>`:""}${tagsHTML}</div>`;
1137
+ }).join("");
1138
+ grid.querySelectorAll(".app-card").forEach(card => {
1139
+ card.addEventListener("click", () => { const newId=createTab(card.dataset.name); navigateTab(newId, card.dataset.url); });
1140
+ });
1141
+ }
1142
+
1143
+ function openAppsTab() {
1144
+ if (appsTabId && tabs.has(appsTabId)) { activateTab(appsTabId); appsBtn.classList.add("active"); return; }
1145
+ appsTabId = createTab("🗂 apps");
1146
+ setTabTitle(appsTabId, "🗂 apps");
1147
+ buildAppsPage(appsTabId);
1148
+ appsBtn.classList.add("active");
1149
+ }
1150
+ appsBtn.addEventListener("click", openAppsTab);
1151
+ </script>
1152
+ </body>
1153
+ </html>
1154
+
1155
+ </html:div>
1156
+
1157
+ </foreignObject>
1158
+
1159
+ </svg>