@indextools/index-games 1.0.1 → 1.0.3

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.
Files changed (238) hide show
  1. package/package.json +1 -1
  2. package/public/config.js +28 -22
  3. package/public/games/10fastfingers.html +12 -0
  4. package/public/games/2048.html +12 -0
  5. package/public/games/absurdle.html +12 -0
  6. package/public/games/actorle.html +12 -0
  7. package/public/games/adventurecapitalist.html +12 -0
  8. package/public/games/agario.html +12 -0
  9. package/public/games/airhockey.html +12 -0
  10. package/public/games/among.html +12 -0
  11. package/public/games/anagram.html +12 -0
  12. package/public/games/angrybirds.html +12 -0
  13. package/public/games/archery.html +12 -0
  14. package/public/games/artquiz.html +12 -0
  15. package/public/games/asteroids.html +12 -0
  16. package/public/games/backgammon.html +12 -0
  17. package/public/games/ballblast.html +12 -0
  18. package/public/games/bandle.html +12 -0
  19. package/public/games/basketballstars.html +12 -0
  20. package/public/games/battleship.html +12 -0
  21. package/public/games/betweenle.html +12 -0
  22. package/public/games/bingo.html +12 -0
  23. package/public/games/blackjack.html +12 -0
  24. package/public/games/blockpuzzle.html +12 -0
  25. package/public/games/bobbleheadbrawl.html +12 -0
  26. package/public/games/bookworm.html +12 -0
  27. package/public/games/bowlingking.html +12 -0
  28. package/public/games/brutal.html +12 -0
  29. package/public/games/bubbshooter.html +12 -0
  30. package/public/games/candycrush.html +12 -0
  31. package/public/games/capitalcities.html +12 -0
  32. package/public/games/cardgame.html +12 -0
  33. package/public/games/carparking.html +12 -0
  34. package/public/games/castlevania.html +12 -0
  35. package/public/games/checkers.html +12 -0
  36. package/public/games/chess.html +12 -0
  37. package/public/games/citybuilder.html +12 -0
  38. package/public/games/clue.html +12 -0
  39. package/public/games/cluelike.html +12 -0
  40. package/public/games/codecombat.html +12 -0
  41. package/public/games/colonist.html +12 -0
  42. package/public/games/colonists.html +12 -0
  43. package/public/games/colorfle.html +12 -0
  44. package/public/games/connectfour.html +12 -0
  45. package/public/games/connections.html +12 -0
  46. package/public/games/contexto.html +12 -0
  47. package/public/games/cookieclicker.html +12 -0
  48. package/public/games/counterblox.html +12 -0
  49. package/public/games/crazycattle.html +12 -0
  50. package/public/games/cribbage.html +12 -0
  51. package/public/games/crossword.html +12 -0
  52. package/public/games/crossyroad.html +12 -0
  53. package/public/games/curling.html +12 -0
  54. package/public/games/cutherope.html +12 -0
  55. package/public/games/darts.html +12 -0
  56. package/public/games/defly.html +12 -0
  57. package/public/games/diablo2d.html +12 -0
  58. package/public/games/dice.html +12 -0
  59. package/public/games/diepio.html +12 -0
  60. package/public/games/dinogame.html +12 -0
  61. package/public/games/doctorgame.html +12 -0
  62. package/public/games/dominoes.html +12 -0
  63. package/public/games/dordle.html +12 -0
  64. package/public/games/doublicator.html +12 -0
  65. package/public/games/driftboss.html +12 -0
  66. package/public/games/drivertest.html +12 -0
  67. package/public/games/dungeoncrawl.html +12 -0
  68. package/public/games/euchre.html +12 -0
  69. package/public/games/ev.html +12 -0
  70. package/public/games/farmidler.html +12 -0
  71. package/public/games/fencing.html +12 -0
  72. package/public/games/fibble.html +12 -0
  73. package/public/games/finalfantasy.html +12 -0
  74. package/public/games/fishdom.html +12 -0
  75. package/public/games/flagle.html +12 -0
  76. package/public/games/flappybird.html +12 -0
  77. package/public/games/foosball.html +12 -0
  78. package/public/games/fortnite2d.html +12 -0
  79. package/public/games/framed.html +12 -0
  80. package/public/games/freecell.html +12 -0
  81. package/public/games/frutninja.html +12 -0
  82. package/public/games/galaxydefense.html +12 -0
  83. package/public/games/games.json +2843 -29
  84. package/public/games/garticphone.html +12 -0
  85. package/public/games/geoguessr.html +12 -0
  86. package/public/games/geoquiz.html +12 -0
  87. package/public/games/getaway.html +12 -0
  88. package/public/games/getgoodgames.html +12 -0
  89. package/public/games/gin.html +12 -0
  90. package/public/games/golfgame.html +12 -0
  91. package/public/games/guessr.html +12 -0
  92. package/public/games/gunblood.html +12 -0
  93. package/public/games/gunfight.html +12 -0
  94. package/public/games/hackeridler.html +12 -0
  95. package/public/games/hangaroo.html +12 -0
  96. package/public/games/heardle.html +12 -0
  97. package/public/games/heartsgame.html +12 -0
  98. package/public/games/heroquest.html +12 -0
  99. package/public/games/historyquiz.html +12 -0
  100. package/public/games/hospitallife.html +12 -0
  101. package/public/games/hoteltycoon.html +12 -0
  102. package/public/games/infinitecraft.html +12 -0
  103. package/public/games/islandtrivia.html +12 -0
  104. package/public/games/jelly.html +12 -0
  105. package/public/games/jewels.html +12 -0
  106. package/public/games/kahoot.html +12 -0
  107. package/public/games/kirka.html +12 -0
  108. package/public/games/knifehit.html +12 -0
  109. package/public/games/krunker.html +12 -0
  110. package/public/games/leaguedle.html +12 -0
  111. package/public/games/letterle.html +12 -0
  112. package/public/games/life.html +12 -0
  113. package/public/games/lightbot.html +12 -0
  114. package/public/games/loldle.html +12 -0
  115. package/public/games/lordz.html +12 -0
  116. package/public/games/magicblast.html +12 -0
  117. package/public/games/mahjong.html +12 -0
  118. package/public/games/mario.html +12 -0
  119. package/public/games/matchmaster.html +12 -0
  120. package/public/games/mathblaster.html +12 -0
  121. package/public/games/mathgame.html +12 -0
  122. package/public/games/mathler.html +12 -0
  123. package/public/games/megaman.html +12 -0
  124. package/public/games/mergedragons.html +12 -0
  125. package/public/games/mergefight.html +12 -0
  126. package/public/games/minecraftclone.html +12 -0
  127. package/public/games/minesweeper.html +12 -0
  128. package/public/games/miniclip.html +12 -0
  129. package/public/games/monopoly.html +12 -0
  130. package/public/games/mope.html +12 -0
  131. package/public/games/moto3.html +12 -0
  132. package/public/games/moviedle.html +12 -0
  133. package/public/games/moviesquiz.html +12 -0
  134. package/public/games/musiquiz.html +12 -0
  135. package/public/games/nationle.html +12 -0
  136. package/public/games/nba2k.html +12 -0
  137. package/public/games/nerdle.html +12 -0
  138. package/public/games/ninjago.html +12 -0
  139. package/public/games/octordle.html +12 -0
  140. package/public/games/pacman.html +12 -0
  141. package/public/games/papergame.html +12 -0
  142. package/public/games/pilotsim.html +12 -0
  143. package/public/games/pinball.html +12 -0
  144. package/public/games/pinochle.html +12 -0
  145. package/public/games/pinturillo.html +12 -0
  146. package/public/games/pirateio.html +12 -0
  147. package/public/games/pizzamaking.html +12 -0
  148. package/public/games/pogo.html +12 -0
  149. package/public/games/pointerpointer.html +12 -0
  150. package/public/games/pokedle.html +12 -0
  151. package/public/games/pokedle2.html +12 -0
  152. package/public/games/pokemonbattle.html +12 -0
  153. package/public/games/pokerclassic.html +12 -0
  154. package/public/games/poolrush.html +12 -0
  155. package/public/games/popculturequiz.html +12 -0
  156. package/public/games/primel.html +12 -0
  157. package/public/games/prodigygame.html +12 -0
  158. package/public/games/questland.html +12 -0
  159. package/public/games/quizlet.html +12 -0
  160. package/public/games/quordle.html +12 -0
  161. package/public/games/reslife.html +12 -0
  162. package/public/games/reversi.html +12 -0
  163. package/public/games/ridleracing.html +12 -0
  164. package/public/games/risk.html +12 -0
  165. package/public/games/roadfury.html +12 -0
  166. package/public/games/rooftopsnipers.html +12 -0
  167. package/public/games/run3.html +12 -0
  168. package/public/games/schoolbus.html +12 -0
  169. package/public/games/sciencequiz.html +12 -0
  170. package/public/games/scrabble.html +12 -0
  171. package/public/games/scratch.html +12 -0
  172. package/public/games/sedecordle.html +12 -0
  173. package/public/games/semantle.html +12 -0
  174. package/public/games/shellshock.html +12 -0
  175. package/public/games/shipsim.html +12 -0
  176. package/public/games/skribbl.html +12 -0
  177. package/public/games/skyblock.html +12 -0
  178. package/public/games/slots.html +12 -0
  179. package/public/games/snakegame.html +12 -0
  180. package/public/games/snakeio.html +12 -0
  181. package/public/games/snowball.html +12 -0
  182. package/public/games/soccerskills.html +12 -0
  183. package/public/games/solitaire.html +12 -0
  184. package/public/games/sonic.html +12 -0
  185. package/public/games/spaceshipshooter.html +12 -0
  186. package/public/games/spacesurvive.html +12 -0
  187. package/public/games/spades.html +12 -0
  188. package/public/games/spellcast.html +12 -0
  189. package/public/games/spellinbee.html +12 -0
  190. package/public/games/spellingbee2.html +12 -0
  191. package/public/games/spidersolitaire.html +12 -0
  192. package/public/games/sportsquiz.html +12 -0
  193. package/public/games/squaredle.html +12 -0
  194. package/public/games/squirdle.html +12 -0
  195. package/public/games/stardew.html +12 -0
  196. package/public/games/starve.html +12 -0
  197. package/public/games/stickmanfight.html +12 -0
  198. package/public/games/stratego.html +12 -0
  199. package/public/games/strategydefense.html +12 -0
  200. package/public/games/stuntcar.html +12 -0
  201. package/public/games/sudoku.html +12 -0
  202. package/public/games/superhero.html +12 -0
  203. package/public/games/superhex.html +12 -0
  204. package/public/games/superhot.html +12 -0
  205. package/public/games/surviv.html +12 -0
  206. package/public/games/sushichef.html +12 -0
  207. package/public/games/tabletopia.html +12 -0
  208. package/public/games/tennisgame.html +12 -0
  209. package/public/games/terraria2d.html +12 -0
  210. package/public/games/tetris.html +12 -0
  211. package/public/games/theimpossiblequiz.html +12 -0
  212. package/public/games/timersniper.html +12 -0
  213. package/public/games/towerblitz.html +12 -0
  214. package/public/games/traindriver.html +12 -0
  215. package/public/games/truckgame.html +12 -0
  216. package/public/games/tunnel.html +12 -0
  217. package/public/games/typeracer.html +12 -0
  218. package/public/games/typingclub.html +12 -0
  219. package/public/games/typingtower.html +12 -0
  220. package/public/games/undergame.html +12 -0
  221. package/public/games/voxiom.html +12 -0
  222. package/public/games/wepons.html +12 -0
  223. package/public/games/wordle.html +12 -0
  224. package/public/games/worldflags.html +12 -0
  225. package/public/games/worldle.html +12 -0
  226. package/public/games/wormate.html +12 -0
  227. package/public/games/wormszone.html +12 -0
  228. package/public/games/zelda.html +12 -0
  229. package/public/games/zombiederby.html +12 -0
  230. package/public/games/zombiesurvive.html +12 -0
  231. package/public/games/zombs.html +12 -0
  232. package/public/games/zuma.html +12 -0
  233. package/public/index.css +30 -0
  234. package/public/index.html +418 -263
  235. package/public/index.svg +33 -50
  236. package/public/register-sw.js +37 -21
  237. package/public/sw.js +42 -6
  238. package/index.svg +0 -53
package/public/index.html CHANGED
@@ -6,6 +6,8 @@
6
6
  <title>Index</title>
7
7
 
8
8
  <script src="config.js"></script>
9
+ <script src="https://unpkg.com/@titaniumnetwork-dev/ultraviolet@3.2.10/dist/uv.bundle.js"></script>
10
+ <script src="https://unpkg.com/@titaniumnetwork-dev/ultraviolet@3.2.10/dist/uv.config.js"></script>
9
11
  <script src="https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js"></script>
10
12
  <script src="https://unpkg.com/@mercuryworkshop/bare-mux@2.1.7/dist/index.js"></script>
11
13
 
@@ -27,7 +29,7 @@
27
29
  </div>
28
30
  </div>
29
31
  <iframe class="game-modal-iframe" id="gm-iframe" allowfullscreen
30
- sandbox="allow-scripts allow-same-origin allow-forms allow-modals"></iframe>
32
+ sandbox="allow-scripts allow-same-origin allow-forms allow-modals allow-popups"></iframe>
31
33
  </div>
32
34
 
33
35
  <div id="app">
@@ -35,22 +37,20 @@
35
37
  <button id="new-tab-btn" title="New tab">+</button>
36
38
  <button id="games-btn" title="Games">🎮 games</button>
37
39
  <button id="apps-btn" title="Apps">🗂 apps</button>
38
- <!-- settings button removed from tab bar — now a FAB -->
39
40
  </div>
40
41
  <div id="main-area">
41
42
  <div id="tab-content"></div>
42
- <div id="settings-panel"></div><!-- kept for legacy JS, hidden via CSS -->
43
+ <div id="settings-panel"></div>
43
44
  </div>
44
45
  </div>
45
46
 
46
- <!-- ── SETTINGS FAB ── -->
47
+ <!-- SETTINGS FAB -->
47
48
  <button id="settings-fab" title="Settings">⚙</button>
48
49
 
49
- <!-- ── SETTINGS DRAWER OVERLAY ── -->
50
+ <!-- SETTINGS DRAWER OVERLAY -->
50
51
  <div id="settings-overlay">
51
52
  <div id="settings-drawer">
52
53
 
53
- <!-- topbar (dynamic) -->
54
54
  <div class="drawer-topbar" id="drawer-topbar">
55
55
  <button class="drawer-back-btn" id="drawer-back" style="display:none">← back</button>
56
56
  <span class="drawer-page-title" id="drawer-title">// settings</span>
@@ -82,7 +82,7 @@
82
82
  <span class="settings-nav-icon">🌐</span>
83
83
  <div>
84
84
  <div>Privacy</div>
85
- <div class="settings-nav-desc">about:blank &amp; proxy</div>
85
+ <div class="settings-nav-desc">about:blank &amp; proxy engine</div>
86
86
  </div>
87
87
  <span class="settings-nav-arrow">›</span>
88
88
  </div>
@@ -95,19 +95,9 @@
95
95
  <span class="settings-nav-arrow">›</span>
96
96
  </div>
97
97
  </div>
98
-
99
- <!--<div class="dsection-label">community</div>
100
- <a href="https://discord.gg/TYPE_HERE" target="_blank" class="drawer-link-btn discord-btn">
101
- <div class="discord-icon">D</div>
102
- <div>
103
- <div>Join our Discord</div>
104
- <div style="font-size:10px;color:#7289da;margin-top:2px;">discord.gg/TYPE_HERE</div>
105
- </div>
106
- <span class="settings-nav-arrow" style="margin-left:auto">↗</span>
107
- </a>-->
108
98
  </div>
109
99
 
110
- <!-- PAGE: appearance (themes) -->
100
+ <!-- PAGE: appearance -->
111
101
  <div class="drawer-page" id="dpage-appearance">
112
102
  <div class="dsection-label">theme</div>
113
103
  <div class="theme-options" id="theme-options">
@@ -177,6 +167,14 @@
177
167
  <div class="cloak-option-icon">📝</div>
178
168
  <div class="cloak-option-info"><div class="cloak-option-name">Schoology</div><div class="cloak-option-url">schoology.com</div></div>
179
169
  </div>
170
+ <div class="cloak-option" data-title="Canvas" data-favicon="https://instructure-uploads.s3.amazonaws.com/account_168/attachments/95820/canvas_logomark_only%402x.png" data-cloak="canvas">
171
+ <div class="cloak-option-icon">🖼️</div>
172
+ <div class="cloak-option-info"><div class="cloak-option-name">Canvas LMS</div><div class="cloak-option-url">canvas.instructure.com</div></div>
173
+ </div>
174
+ <div class="cloak-option" data-title="Duolingo" data-favicon="https://d35aaqx5ub95lt.cloudfront.net/favicon.ico" data-cloak="duolingo">
175
+ <div class="cloak-option-icon">🦜</div>
176
+ <div class="cloak-option-info"><div class="cloak-option-name">Duolingo</div><div class="cloak-option-url">duolingo.com</div></div>
177
+ </div>
180
178
  </div>
181
179
  <div class="dsection-note">changes the tab title and favicon — won't affect other users.</div>
182
180
  </div>
@@ -192,6 +190,27 @@
192
190
  </div>
193
191
  </button>
194
192
  <div class="dsection-note">opens proxy pages in a popup showing about:blank in the address bar.</div>
193
+
194
+ <div class="dsection-label" style="margin-top:18px;">proxy engine</div>
195
+ <div class="proxy-options" id="proxy-options">
196
+ <div class="proxy-option selected" data-proxy="scramjet">
197
+ <div class="proxy-option-icon">⚡</div>
198
+ <div class="proxy-option-info">
199
+ <div class="proxy-option-name">ScramJet</div>
200
+ <div class="proxy-option-desc">fastest — experimental, best for most sites</div>
201
+ </div>
202
+ <span class="proxy-check">✓</span>
203
+ </div>
204
+ <div class="proxy-option" data-proxy="ultraviolet">
205
+ <div class="proxy-option-icon">🔵</div>
206
+ <div class="proxy-option-info">
207
+ <div class="proxy-option-name">Ultraviolet</div>
208
+ <div class="proxy-option-desc">stable — better compat for older sites</div>
209
+ </div>
210
+ <span class="proxy-check">✓</span>
211
+ </div>
212
+ </div>
213
+ <div class="dsection-note">switch proxy engines if a site won't load.</div>
195
214
  </div>
196
215
 
197
216
  <!-- PAGE: about -->
@@ -205,36 +224,31 @@
205
224
  </div>
206
225
 
207
226
  <div class="about-desc">
208
- 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!
227
+ Index is a proxy site for bypassing network restrictions. Supports both ScramJet and Ultraviolet proxy engines — toggle them in Privacy settings if a site won't load.
209
228
  </div>
210
229
 
211
230
  <div class="about-row">
212
231
  <span class="about-row-label">proxy engine</span>
213
- <span class="about-row-val">ScramJet {experimental}<span class="about-badge">active</span></span>
232
+ <span class="about-row-val" id="about-proxy-label">ScramJet<span class="about-badge" id="about-proxy-badge">active</span></span>
214
233
  </div>
215
234
  <div class="about-row">
216
235
  <span class="about-row-label">version</span>
217
- <span class="about-row-val">v0.0.6</span>
236
+ <span class="about-row-val">v0.1.0</span>
218
237
  </div>
219
238
  <div class="about-row">
220
239
  <span class="about-row-label">max tabs</span>
221
240
  <span class="about-row-val">20</span>
222
241
  </div>
242
+ <div class="about-row">
243
+ <span class="about-row-label">games</span>
244
+ <span class="about-row-val">244+</span>
245
+ </div>
223
246
 
224
- <div class="dsection-label" style="margin-top:20px;">scramjet</div>
247
+ <div class="dsection-label" style="margin-top:20px;">engines</div>
225
248
  <div class="about-desc">
226
- best proxt!
249
+ ScramJet (default) — fastest, modern rewriting. Ultraviolet — legacy fallback with high compatibility. Both run through epoxy transport for maximum speed.
227
250
  </div>
228
-
229
- <!--<a href="https://discord.gg/TYPE_HERE" target="_blank" class="drawer-link-btn discord-btn" style="margin-top:4px;">
230
- <div class="discord-icon">D</div>
231
- <div>
232
- <div>Join our Discord</div>
233
- <div style="font-size:10px;color:#7289da;margin-top:2px;">community &amp; support</div>
234
- </div>
235
- <span style="margin-left:auto;color:var(--text-dim)">↗</span>
236
- </a>
237
- </div>-->
251
+ </div>
238
252
 
239
253
  </div><!-- /drawer-body -->
240
254
  </div><!-- /settings-drawer -->
@@ -244,7 +258,60 @@
244
258
  "use strict";
245
259
 
246
260
  /* ══════════════════════════════════════════
247
- CANVAS / THEMES (unchanged from original)
261
+ SVG CONTEXT DETECTION
262
+ The page may be loaded as a plain .html OR embedded inside
263
+ index.svg via <foreignObject>. We normalise baseHref here so
264
+ all relative resource fetches (games.json, icons, sw.js) work
265
+ in both contexts.
266
+ ══════════════════════════════════════════ */
267
+ (function patchBaseHref() {
268
+ // If we're inside an SVG foreignObject the document.URL might
269
+ // point at index.svg. Force a <base> tag so relative URLs
270
+ // resolve against the HTML directory, not the SVG.
271
+ const loc = document.URL || location.href;
272
+ if (loc.endsWith(".svg") || loc.includes(".svg?") || loc.includes(".svg#")) {
273
+ // Try to construct the sibling index.html path
274
+ const htmlBase = loc.replace(/index\.svg[^/]*$/, "");
275
+ let base = document.querySelector("base");
276
+ if (!base) {
277
+ base = document.createElement("base");
278
+ document.head.insertBefore(base, document.head.firstChild);
279
+ }
280
+ if (!base.href || base.href === loc) {
281
+ base.href = htmlBase;
282
+ }
283
+ }
284
+ })();
285
+
286
+ /* ══════════════════════════════════════════
287
+ PROXY ENGINE STATE
288
+ 'scramjet' | 'ultraviolet'
289
+ ══════════════════════════════════════════ */
290
+ let activeProxy = localStorage.getItem("proxyEngine") || "scramjet";
291
+
292
+ function saveProxyEngine(name) {
293
+ activeProxy = name;
294
+ localStorage.setItem("proxyEngine", name);
295
+ document.querySelectorAll(".proxy-option").forEach(o => {
296
+ o.classList.toggle("selected", o.dataset.proxy === name);
297
+ });
298
+ // Update about page label
299
+ const lbl = document.getElementById("about-proxy-label");
300
+ const bdg = document.getElementById("about-proxy-badge");
301
+ if (lbl) lbl.firstChild.textContent = name === "scramjet" ? "ScramJet" : "Ultraviolet";
302
+ if (bdg) bdg.textContent = "active";
303
+ }
304
+
305
+ document.getElementById("proxy-options").addEventListener("click", function(e) {
306
+ const opt = e.target.closest(".proxy-option");
307
+ if (!opt) return;
308
+ saveProxyEngine(opt.dataset.proxy);
309
+ // Reset transport ready flag so next navigate re-inits with new engine
310
+ transportReady = false;
311
+ });
312
+
313
+ /* ══════════════════════════════════════════
314
+ CANVAS / THEMES
248
315
  ══════════════════════════════════════════ */
249
316
  const canvas = document.getElementById("bg-canvas");
250
317
  const ctx = canvas.getContext("2d");
@@ -257,25 +324,10 @@
257
324
  r: Math.random() * 2 + 0.3,
258
325
  speed: Math.random() * 0.00015 + 0.00005,
259
326
  drift: (Math.random() - 0.5) * 0.0001,
260
- opacity: Math.random() * 0.7 + 0.3
327
+ opacity: Math.random() * 0.7 + 0.3,
328
+ offset: Math.random() * Math.PI * 2,
261
329
  }));
262
330
 
263
- const LINE_COUNT = 51;
264
- const waveLines = Array.from({length: LINE_COUNT}, (_, i) => {
265
- const points = 120;
266
- return {
267
- baseY: (i + 1) / (LINE_COUNT + 1),
268
- points: Array.from({length: points}, (_, j) => ({
269
- x: j / (points - 1),
270
- offset: Math.random() * Math.PI * 2,
271
- speed: 0.003 + Math.random() * 0.002,
272
- amp: 0.012 + Math.random() * 0.018,
273
- mouseInfluence: 0
274
- }))
275
- };
276
- });
277
- let waveT = 0;
278
-
279
331
  const fernNodes = Array.from({length: 40}, () => ({
280
332
  x: Math.random() * window.innerWidth,
281
333
  y: Math.random() * window.innerHeight,
@@ -333,40 +385,36 @@
333
385
  window.addEventListener("resize", resizeCanvas);
334
386
  resizeCanvas();
335
387
 
388
+ let waveT = 0;
389
+
336
390
  function drawNexora() {
337
391
  const W = canvas.width, H = canvas.height;
338
392
  ctx.clearRect(0, 0, W, H);
339
393
  const grad = ctx.createRadialGradient(W*0.4, H*0.5, 0, W*0.5, H*0.5, W*0.8);
340
394
  grad.addColorStop(0, "rgba(30,10,0,0.95)");
341
395
  grad.addColorStop(1, "rgba(5,2,0,0.98)");
342
- ctx.fillStyle = grad;
343
- ctx.fillRect(0, 0, W, H);
396
+ ctx.fillStyle = grad; ctx.fillRect(0, 0, W, H);
344
397
  for (const s of stars) {
345
398
  s.x += s.speed; s.y += s.drift;
346
399
  if (s.x > 1) s.x = 0;
347
- if (s.y > 1) s.y = 0;
348
- if (s.y < 0) s.y = 1;
400
+ if (s.y > 1) s.y = 0; if (s.y < 0) s.y = 1;
349
401
  const sx = s.x * W, sy = s.y * H;
350
- const twinkle = 0.5 + 0.5 * Math.sin(Date.now() * 0.002 * s.speed * 300 + s.offset || 0);
351
- ctx.beginPath();
352
- ctx.arc(sx, sy, s.r, 0, Math.PI * 2);
353
- ctx.fillStyle = `rgba(255,220,180,${s.opacity * (0.6 + 0.4 * twinkle)})`;
354
- ctx.fill();
402
+ const twinkle = 0.5 + 0.5 * Math.sin(Date.now() * 0.002 * s.speed * 300 + s.offset);
403
+ ctx.beginPath(); ctx.arc(sx, sy, s.r, 0, Math.PI * 2);
404
+ ctx.fillStyle = `rgba(255,220,180,${s.opacity * (0.6 + 0.4 * twinkle)})`; ctx.fill();
355
405
  }
356
406
  const orb = ctx.createRadialGradient(W*0.35, H*0.55, 0, W*0.35, H*0.55, W*0.45);
357
407
  orb.addColorStop(0, "rgba(255,80,0,0.12)");
358
408
  orb.addColorStop(0.5, "rgba(255,40,0,0.05)");
359
409
  orb.addColorStop(1, "transparent");
360
- ctx.fillStyle = orb;
361
- ctx.fillRect(0, 0, W, H);
410
+ ctx.fillStyle = orb; ctx.fillRect(0, 0, W, H);
362
411
  animFrame = requestAnimationFrame(drawNexora);
363
412
  }
364
413
 
365
414
  function drawWave() {
366
415
  const W = canvas.width, H = canvas.height;
367
416
  ctx.clearRect(0, 0, W, H);
368
- ctx.fillStyle = "#1a2530";
369
- ctx.fillRect(0, 0, W, H);
417
+ ctx.fillStyle = "#1a2530"; ctx.fillRect(0, 0, W, H);
370
418
  waveT += 0.004;
371
419
  const TOTAL_LINES = 120;
372
420
  for (let li = 0; li < TOTAL_LINES; li++) {
@@ -376,13 +424,11 @@
376
424
  const baseColor = isAccent
377
425
  ? `rgba(${80 + accentStrength * 100},${180 + accentStrength * 60},${80 + accentStrength * 20},${0.4 + accentStrength * 0.5})`
378
426
  : `rgba(60,100,75,${0.06 + t * 0.12})`;
379
- ctx.beginPath();
380
- ctx.strokeStyle = baseColor;
427
+ ctx.beginPath(); ctx.strokeStyle = baseColor;
381
428
  ctx.lineWidth = isAccent ? 1.5 + accentStrength * 1.5 : 0.6;
382
429
  const STEPS = 300;
383
430
  for (let si = 0; si <= STEPS; si++) {
384
- const x = (si / STEPS) * W;
385
- const px = si / STEPS;
431
+ const x = (si / STEPS) * W, px = si / STEPS;
386
432
  const dx = px - mouseX, dy = t - mouseY;
387
433
  const dist = Math.sqrt(dx * dx + dy * dy * 4);
388
434
  const repel = dist < 0.12 ? (0.12 - dist) / 0.12 : 0;
@@ -391,9 +437,8 @@
391
437
  const w2 = Math.sin(px * 11 - waveT * 0.7 + li * 0.31) * 0.014;
392
438
  const w3 = Math.sin(px * 2 + waveT * 0.4 + li * 0.09) * 0.045;
393
439
  const w4 = Math.sin(px * 18 + waveT * 1.8 + li * 0.55) * 0.006;
394
- const baseY = t + 0.02;
395
- const y = (baseY + w1 + w2 + w3 + w4 + repel * repelDir * 0.06) * H;
396
- if (si === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
440
+ const y = (t + 0.02 + w1 + w2 + w3 + w4 + repel * repelDir * 0.06) * H;
441
+ si === 0 ? ctx.moveTo(x, y) : ctx.lineTo(x, y);
397
442
  }
398
443
  ctx.stroke();
399
444
  }
@@ -404,8 +449,7 @@
404
449
  function drawVoid() {
405
450
  const W = canvas.width, H = canvas.height;
406
451
  ctx.clearRect(0, 0, W, H);
407
- ctx.fillStyle = "#000000";
408
- ctx.fillRect(0, 0, W, H);
452
+ ctx.fillStyle = "#000000"; ctx.fillRect(0, 0, W, H);
409
453
  voidT += 0.004;
410
454
  const TOTAL_LINES = 100;
411
455
  for (let li = 0; li < TOTAL_LINES; li++) {
@@ -413,13 +457,11 @@
413
457
  const isAccent = li >= TOTAL_LINES - 3;
414
458
  const accentStrength = isAccent ? (li - (TOTAL_LINES - 3)) / 3 : 0;
415
459
  const alpha = isAccent ? 0.55 + accentStrength * 0.45 : 0.04 + t * 0.18;
416
- ctx.beginPath();
417
- ctx.strokeStyle = `rgba(255,255,255,${alpha})`;
460
+ ctx.beginPath(); ctx.strokeStyle = `rgba(255,255,255,${alpha})`;
418
461
  ctx.lineWidth = isAccent ? 1.2 + accentStrength * 1.0 : 0.5;
419
462
  const STEPS = 300;
420
463
  for (let si = 0; si <= STEPS; si++) {
421
- const x = (si / STEPS) * W;
422
- const px = si / STEPS;
464
+ const x = (si / STEPS) * W, px = si / STEPS;
423
465
  const dx = px - mouseX, dy = t - mouseY;
424
466
  const dist = Math.sqrt(dx * dx + dy * dy * 4);
425
467
  const repel = dist < 0.12 ? (0.12 - dist) / 0.12 : 0;
@@ -428,9 +470,8 @@
428
470
  const w2 = Math.sin(px * 9 - voidT * 0.6 + li * 0.28) * 0.016;
429
471
  const w3 = Math.sin(px * 2.5 + voidT * 0.35 + li * 0.10) * 0.050;
430
472
  const w4 = Math.sin(px * 16 + voidT * 1.5 + li * 0.50) * 0.007;
431
- const baseY = t + 0.02;
432
- const y = (baseY + w1 + w2 + w3 + w4 + repel * repelDir * 0.06) * H;
433
- if (si === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
473
+ const y = (t + 0.02 + w1 + w2 + w3 + w4 + repel * repelDir * 0.06) * H;
474
+ si === 0 ? ctx.moveTo(x, y) : ctx.lineTo(x, y);
434
475
  }
435
476
  ctx.stroke();
436
477
  }
@@ -440,15 +481,12 @@
440
481
  function drawFern() {
441
482
  const W = canvas.width, H = canvas.height;
442
483
  ctx.clearRect(0, 0, W, H);
443
- ctx.fillStyle = "#000000";
444
- ctx.fillRect(0, 0, W, H);
484
+ ctx.fillStyle = "#000000"; ctx.fillRect(0, 0, W, H);
445
485
  const now = Date.now() * 0.001;
446
486
  for (const s of fernStars) {
447
487
  const twinkle = 0.6 + 0.4 * Math.sin(now * 1.2 + s.twinkleOffset);
448
- ctx.beginPath();
449
- ctx.arc(s.x * W, s.y * H, s.r, 0, Math.PI * 2);
450
- ctx.fillStyle = `rgba(255,255,255,${s.opacity * twinkle})`;
451
- ctx.fill();
488
+ ctx.beginPath(); ctx.arc(s.x * W, s.y * H, s.r, 0, Math.PI * 2);
489
+ ctx.fillStyle = `rgba(255,255,255,${s.opacity * twinkle})`; ctx.fill();
452
490
  }
453
491
  const mx = mouseX * W, my = mouseY * H;
454
492
  for (const n of fernNodes) {
@@ -456,8 +494,7 @@
456
494
  const dist = Math.sqrt(dx * dx + dy * dy);
457
495
  if (dist < 100 && dist > 0) {
458
496
  const force = (100 - dist) / 100 * 0.4;
459
- n.vx += (dx / dist) * force;
460
- n.vy += (dy / dist) * force;
497
+ n.vx += (dx / dist) * force; n.vy += (dy / dist) * force;
461
498
  }
462
499
  const speed = Math.sqrt(n.vx * n.vx + n.vy * n.vy);
463
500
  if (speed > 1.2) { n.vx = (n.vx / speed) * 1.2; n.vy = (n.vy / speed) * 1.2; }
@@ -481,30 +518,23 @@
481
518
  }
482
519
  }
483
520
  for (const n of fernNodes) {
484
- ctx.beginPath();
485
- ctx.arc(n.x, n.y, n.r, 0, Math.PI * 2);
486
- ctx.fillStyle = "rgba(255,255,255,0.5)";
487
- ctx.fill();
521
+ ctx.beginPath(); ctx.arc(n.x, n.y, n.r, 0, Math.PI * 2);
522
+ ctx.fillStyle = "rgba(255,255,255,0.5)"; ctx.fill();
488
523
  }
489
524
  fernShootingTimer++;
490
525
  if (fernShootingTimer > 180 + Math.random() * 240) {
491
- spawnShootingStar();
492
- fernShootingTimer = 0;
526
+ spawnShootingStar(); fernShootingTimer = 0;
493
527
  }
494
528
  shootingStars = shootingStars.filter(s => s.life > 0);
495
529
  for (const s of shootingStars) {
496
530
  const tx = s.x + Math.cos(s.angle) * s.len;
497
531
  const ty = s.y + Math.sin(s.angle) * s.len;
498
532
  const grad = ctx.createLinearGradient(s.x, s.y, tx, ty);
499
- grad.addColorStop(0, `rgba(255,255,255,0)`);
533
+ grad.addColorStop(0, "rgba(255,255,255,0)");
500
534
  grad.addColorStop(0.3, `rgba(255,255,255,${s.life * 0.6})`);
501
535
  grad.addColorStop(1, `rgba(255,255,255,${s.life})`);
502
- ctx.beginPath();
503
- ctx.strokeStyle = grad;
504
- ctx.lineWidth = 1.5;
505
- ctx.moveTo(s.x, s.y);
506
- ctx.lineTo(tx, ty);
507
- ctx.stroke();
536
+ ctx.beginPath(); ctx.strokeStyle = grad; ctx.lineWidth = 1.5;
537
+ ctx.moveTo(s.x, s.y); ctx.lineTo(tx, ty); ctx.stroke();
508
538
  s.x += Math.cos(s.angle) * s.speed;
509
539
  s.y += Math.sin(s.angle) * s.speed;
510
540
  s.life -= s.decay;
@@ -536,18 +566,9 @@
536
566
  drawVoid();
537
567
  } else if (theme === "fern") {
538
568
  document.body.classList.add("theme-fern");
539
- shootingStars = [];
540
- fernShootingTimer = 0;
569
+ shootingStars = []; fernShootingTimer = 0;
541
570
  drawFern();
542
571
  }
543
- updateQuickAppColors();
544
- }
545
-
546
- function updateQuickAppColors() {
547
- const color = getComputedStyle(document.documentElement).getPropertyValue("--green").trim() || "#4ab464";
548
- document.querySelectorAll(".quick-app-icon svg path, .quick-app-icon svg polygon").forEach(el => {
549
- if (el.getAttribute("fill") && el.getAttribute("fill") !== "none") el.setAttribute("fill", color);
550
- });
551
572
  }
552
573
 
553
574
  document.getElementById("theme-options").addEventListener("click", function(e) {
@@ -557,15 +578,32 @@
557
578
  });
558
579
 
559
580
  /* ══════════════════════════════════════════
560
- CLOAK
581
+ CLOAK — works in both HTML and SVG context
561
582
  ══════════════════════════════════════════ */
562
583
  let currentCloak = { title: "Index", favicon: "", cloak: "none" };
563
584
 
564
585
  function applyCloak(title, favicon) {
565
- document.title = title;
586
+ // Set document title
587
+ try { document.title = title; } catch(_) {}
588
+ // Set favicon — works in HTML context; in SVG context this is a no-op
589
+ // but that's fine because the SVG wrapper's containing document controls
590
+ // the browser tab, not the foreignObject.
566
591
  let link = document.querySelector("link[rel~='icon']");
567
- if (!link) { link = document.createElement("link"); link.rel = "icon"; document.head.appendChild(link); }
592
+ if (!link) {
593
+ link = document.createElement("link");
594
+ link.rel = "shortcut icon";
595
+ document.head.appendChild(link);
596
+ }
568
597
  link.href = favicon || "data:,";
598
+
599
+ // In SVG context: also try to reach the parent window
600
+ try {
601
+ if (window.parent && window.parent !== window) {
602
+ window.parent.document.title = title;
603
+ const pLink = window.parent.document.querySelector("link[rel~='icon']");
604
+ if (pLink) pLink.href = favicon || "data:,";
605
+ }
606
+ } catch(_) {}
569
607
  }
570
608
 
571
609
  document.getElementById("cloak-options").addEventListener("click", function(e) {
@@ -585,7 +623,13 @@
585
623
  const entry = tabs.get(activeId);
586
624
  let url = null;
587
625
  if (entry && entry.frame) {
588
- try { url = entry.frame.frame.contentWindow.location.href; } catch(_) {}
626
+ try {
627
+ if (activeProxy === "ultraviolet" && entry.uvFrame) {
628
+ url = entry.uvFrame.src;
629
+ } else if (entry.frame && entry.frame.frame) {
630
+ url = entry.frame.frame.contentWindow.location.href;
631
+ }
632
+ } catch(_) {}
589
633
  }
590
634
  if (!url || url === "about:blank") {
591
635
  url = prompt("Enter a URL to open in about:blank:");
@@ -598,29 +642,49 @@
598
642
  function openAboutBlank(url) {
599
643
  const win = window.open("about:blank", "_blank");
600
644
  if (!win) { alert("Allow popups for about:blank to work."); return; }
601
- const baseDir = new URL("./", location.href).pathname;
602
- const workerPath = new URL("baremux/worker.js", location.href).pathname;
603
- const swScriptPath = new URL("register-sw.js", location.href).pathname;
604
- const scramjetPrefix = baseDir + "service/";
645
+ // Resolve base relative to HTML file not SVG
646
+ const base = (() => {
647
+ const b = document.querySelector("base");
648
+ return (b && b.href && !b.href.endsWith(".svg")) ? b.href : (location.origin + location.pathname.replace(/index\.svg$/, ""));
649
+ })();
650
+ const workerPath = base + "baremux/worker.js";
651
+ const swScriptPath = base + "register-sw.js";
652
+ const scramjetPrefix = base + "service/";
653
+ const uvPrefix = base + "uv/";
654
+ const proxyToUse = activeProxy;
655
+
605
656
  win.document.open();
606
657
  win.document.write(`<!doctype html><html><head>
607
658
  <script src="https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js"><\/script>
659
+ <script src="https://unpkg.com/@titaniumnetwork-dev/ultraviolet@3.2.10/dist/uv.bundle.js"><\/script>
660
+ <script src="https://unpkg.com/@titaniumnetwork-dev/ultraviolet@3.2.10/dist/uv.config.js"><\/script>
608
661
  <script src="https://unpkg.com/@mercuryworkshop/bare-mux@2.1.7/dist/index.js"><\/script>
609
662
  <script src="${swScriptPath}"><\/script>
610
663
  <style>*{margin:0;padding:0;}iframe{width:100vw;height:100vh;border:none;}<\/style>
611
664
  </head><body><script>
612
665
  (async()=>{
613
- const {ScramjetController}=$scramjetLoadController();
614
- 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"}});
615
- sj.init();
616
666
  await registerSW();
617
- const c=new BareMux.BareMuxConnection("${workerPath}");
618
- const wispUrl=(location.host && location.host.includes("unpkg.com")) ? "wss://wisp.mercurywork.shop/" : ((location.protocol==="https:"?"wss":"ws")+"://"+location.host+"/wisp/");
619
- const transportUrl="https://unpkg.com/@mercuryworkshop/libcurl-transport@1.5.2/dist/index.mjs";
620
- if((await c.getTransport())!==transportUrl)await c.setTransport(transportUrl,[{websocket:wispUrl}]);
621
- const f=sj.createFrame();
622
- document.body.appendChild(f.frame);
623
- f.go("${url}");
667
+ const c = new BareMux.BareMuxConnection("${workerPath}");
668
+ const wispUrl = (location.protocol==="https:"?"wss":"ws")+"://"+location.host+"/wisp/";
669
+ const transport = "https://unpkg.com/@mercuryworkshop/epoxy-transport@2.1.29/dist/index.mjs";
670
+ if((await c.getTransport()) !== transport) await c.setTransport(transport,[{websocket:wispUrl}]);
671
+ const f = document.createElement("iframe");
672
+ f.style.cssText = "width:100%;height:100%;border:none;position:fixed;inset:0;";
673
+ f.allow = "gamepad *";
674
+ document.body.appendChild(f);
675
+ const proxy = "${proxyToUse}";
676
+ if(proxy === "ultraviolet") {
677
+ if(self.__uv\$config) self.__uv\$config.prefix = "${uvPrefix}";
678
+ f.src = __uv\$config.prefix + __uv\$config.encodeUrl("${url}");
679
+ } else {
680
+ const {ScramjetController} = \$scramjetLoadController();
681
+ 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"}});
682
+ sj.init();
683
+ const frame = sj.createFrame();
684
+ document.body.innerHTML = "";
685
+ document.body.appendChild(frame.frame);
686
+ frame.go("${url}");
687
+ }
624
688
  })();
625
689
  <\/script></body></html>`);
626
690
  win.document.close();
@@ -652,10 +716,7 @@
652
716
  drawerBack.style.display = pageHistory.length > 1 ? "inline-flex" : "none";
653
717
  }
654
718
 
655
- function gotoPage(pageId) {
656
- pageHistory.push(pageId);
657
- showPage(pageId);
658
- }
719
+ function gotoPage(pageId) { pageHistory.push(pageId); showPage(pageId); }
659
720
 
660
721
  drawerBack.addEventListener("click", () => {
661
722
  if (pageHistory.length <= 1) return;
@@ -670,112 +731,104 @@
670
731
  fab.addEventListener("click", () => {
671
732
  const open = overlay.classList.toggle("open");
672
733
  fab.classList.toggle("active", open);
673
- if (open) {
674
- pageHistory = ["dpage-main"];
675
- showPage("dpage-main");
676
- }
734
+ if (open) { pageHistory = ["dpage-main"]; showPage("dpage-main"); }
677
735
  });
678
736
 
679
737
  overlay.addEventListener("click", e => {
680
- if (e.target === overlay) {
681
- overlay.classList.remove("open");
682
- fab.classList.remove("active");
683
- }
738
+ if (e.target === overlay) { overlay.classList.remove("open"); fab.classList.remove("active"); }
684
739
  });
685
740
 
686
- drawerClose.addEventListener("click", () => {
687
- overlay.classList.remove("open");
688
- fab.classList.remove("active");
689
- });
690
-
691
- /* ══════════════════════════════════════════
692
- RESTORE SETTINGS
693
- ══════════════════════════════════════════ */
694
- (function restoreSettings() {
695
- const savedCloak = localStorage.getItem("cloak");
696
- if (savedCloak) {
697
- try {
698
- const c = JSON.parse(savedCloak);
699
- currentCloak = c;
700
- applyCloak(c.title, c.favicon);
701
- document.querySelectorAll(".cloak-option").forEach(o => {
702
- o.classList.toggle("selected", o.dataset.cloak === c.cloak);
703
- });
704
- } catch(_) {}
705
- }
706
- const savedTheme = localStorage.getItem("theme") || "default";
707
- applyTheme(savedTheme);
708
- })();
741
+ drawerClose.addEventListener("click", () => { overlay.classList.remove("open"); fab.classList.remove("active"); });
709
742
 
710
743
  /* ══════════════════════════════════════════
711
- QUICK APPS / APPS REGISTRY (unchanged)
744
+ PROXY ENGINE INIT — ScramJet + UV
712
745
  ══════════════════════════════════════════ */
713
- const QUICK_APPS = [
714
- { 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;" />` },
715
- { 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;" />` },
716
- { 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;" />` },
717
- { 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;" />` },
718
- { 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;" />` },
719
- { 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;" />` },
720
- { 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;" />` },
721
- { name: "music", url: "https://freefy.app/", icon: `<img src="icons/MCTF-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
722
- { 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;" />` },
723
- ];
724
-
725
- const APPS_REGISTRY = [
726
- { 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"] },
727
- { 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"] },
728
- { 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"] },
729
- { 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"] },
730
- { 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"] },
731
- { 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"] },
732
- { 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"] },
733
- { 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"] },
734
- { 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"] },
735
- { 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"] },
736
- { 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"] },
737
- { 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"] },
738
- { 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"] },
739
- { 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"] },
740
- { 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"] },
741
- { 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"] },
742
- { 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"] },
743
- { 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"] },
744
- ];
745
-
746
746
  const cfg = (typeof window !== "undefined" && window.__INDEX_CONFIG) || {};
747
747
  const scramjetFiles = cfg.scramjet || {
748
748
  wasm: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.wasm.wasm",
749
749
  all: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js",
750
- sync: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js"
750
+ sync: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js",
751
751
  };
752
- const baseDir = new URL("./", location.href).pathname;
753
- const workerPath = (cfg.baremux && cfg.baremux.worker) || new URL("baremux/worker.js", location.href).pathname;
752
+
753
+ // Resolve base so both engines use the right path regardless of SVG/HTML loading
754
+ const baseDir = (() => {
755
+ const b = document.querySelector("base");
756
+ if (b && b.href && !b.href.endsWith(".svg")) {
757
+ return new URL("./", b.href).pathname;
758
+ }
759
+ return new URL("./", location.href).pathname;
760
+ })();
761
+
762
+ const workerPath = (cfg.baremux && cfg.baremux.worker) || (baseDir + "baremux/worker.js");
754
763
  const scramjetPrefix = baseDir + "service/";
764
+ const uvPrefix = baseDir + "uv/";
755
765
 
766
+ // Init ScramJet
756
767
  const { ScramjetController } = $scramjetLoadController();
757
- const scramjet = new ScramjetController({
758
- files: scramjetFiles,
759
- prefix: scramjetPrefix
760
- });
768
+ const scramjet = new ScramjetController({ files: scramjetFiles, prefix: scramjetPrefix });
761
769
  scramjet.init();
762
770
 
771
+ // UV config prefix
772
+ if (self.__uv$config) {
773
+ self.__uv$config.prefix = uvPrefix;
774
+ }
775
+
763
776
  const connection = new BareMux.BareMuxConnection(workerPath);
764
777
  let transportReady = false;
765
778
 
766
779
  async function ensureTransport() {
767
780
  if (transportReady) return;
768
- await registerSW();
769
- const wispUrl = cfg.wispUrl || (location.host && location.host.includes("unpkg.com") ? "wss://wisp.mercurywork.shop/" : ((location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/"));
770
- const transportUrl = (cfg.libcurl && cfg.libcurl.transport) || "https://unpkg.com/@mercuryworkshop/libcurl-transport@1.5.2/dist/index.mjs";
771
- if ((await connection.getTransport()) !== transportUrl) {
781
+ if (typeof registerSW === "function") await registerSW();
782
+ const wispUrl = cfg.wispUrl ||
783
+ ((location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/");
784
+ // Prefer epoxy (Rust/Wasm, fastest), fall back to libcurl
785
+ const transportUrl = (cfg.epoxy && cfg.epoxy.transport)
786
+ || (cfg.transport)
787
+ || "https://unpkg.com/@mercuryworkshop/epoxy-transport@2.1.29/dist/index.mjs";
788
+ const current = await connection.getTransport().catch(() => null);
789
+ if (current !== transportUrl) {
772
790
  await connection.setTransport(transportUrl, [{ websocket: wispUrl }]);
773
791
  }
774
792
  transportReady = true;
775
793
  }
776
794
 
777
795
  /* ══════════════════════════════════════════
778
- TAB ENGINE (unchanged)
796
+ NAVIGATE WITH ACTIVE PROXY ENGINE
797
+ ══════════════════════════════════════════ */
798
+ async function proxyNavigate(entry, url, id) {
799
+ if (activeProxy === "ultraviolet" && self.__uv$config) {
800
+ // UV uses a plain iframe with encoded URL
801
+ if (!entry.uvFrame) {
802
+ entry.uvFrame = document.createElement("iframe");
803
+ entry.uvFrame.style.cssText = "width:100%;height:100%;border:none;";
804
+ entry.uvFrame.allow = "gamepad *";
805
+ entry.uvFrame.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms allow-modals allow-popups");
806
+ }
807
+ entry.paneEl.innerHTML = "";
808
+ entry.paneEl.appendChild(entry.uvFrame);
809
+ entry.uvFrame.src = __uv$config.prefix + __uv$config.encodeUrl(url);
810
+ entry.uvFrame.onload = () => {
811
+ setTabLoading(id, false);
812
+ try {
813
+ const t = entry.uvFrame.contentDocument?.title;
814
+ if (t) setTabTitle(id, t);
815
+ } catch(_) {}
816
+ };
817
+ } else {
818
+ // ScramJet
819
+ if (!entry.frame) entry.frame = scramjet.createFrame();
820
+ entry.paneEl.innerHTML = "";
821
+ entry.paneEl.appendChild(entry.frame.frame);
822
+ entry.frame.go(url);
823
+ entry.frame.frame.addEventListener("load", function() {
824
+ setTabLoading(id, false);
825
+ try { const t = entry.frame.frame.contentDocument?.title; if (t) setTabTitle(id, t); } catch(_) {}
826
+ }, { once: true });
827
+ }
828
+ }
829
+
830
+ /* ══════════════════════════════════════════
831
+ TAB ENGINE
779
832
  ══════════════════════════════════════════ */
780
833
  const tabBar = document.getElementById("tab-bar");
781
834
  const newTabBtn = document.getElementById("new-tab-btn");
@@ -805,7 +858,8 @@
805
858
  paneEl.innerHTML = getHomeHTML(id);
806
859
  tabBar.insertBefore(tabEl, newTabBtn);
807
860
  tabContent.appendChild(paneEl);
808
- tabs.set(id, { tabEl, paneEl, frame: null });
861
+ const entry = { tabEl, paneEl, frame: null, uvFrame: null };
862
+ tabs.set(id, entry);
809
863
  wireHome(paneEl, id);
810
864
  tabEl.addEventListener("click", e => { if (!e.target.classList.contains("tab-close")) activateTab(id); });
811
865
  tabEl.querySelector(".tab-close").addEventListener("click", e => { e.stopPropagation(); closeTab(id); });
@@ -819,6 +873,9 @@
819
873
  tabEl.classList.toggle("active", tid === id);
820
874
  paneEl.classList.toggle("active", tid === id);
821
875
  });
876
+ // Manage games/apps button active state
877
+ document.getElementById("games-btn").classList.toggle("active", id === gamesTabId);
878
+ document.getElementById("apps-btn").classList.toggle("active", id === appsTabId);
822
879
  }
823
880
 
824
881
  function closeTab(id) {
@@ -826,6 +883,8 @@
826
883
  const entry = tabs.get(id); if (!entry) return;
827
884
  const keys = [...tabs.keys()], idx = keys.indexOf(id);
828
885
  entry.tabEl.remove(); entry.paneEl.remove(); tabs.delete(id);
886
+ if (id === gamesTabId) gamesTabId = null;
887
+ if (id === appsTabId) appsTabId = null;
829
888
  if (activeId === id) {
830
889
  const r = [...tabs.keys()];
831
890
  activateTab(r[Math.min(idx, r.length - 1)]);
@@ -838,29 +897,67 @@
838
897
  try { await ensureTransport(); }
839
898
  catch (err) {
840
899
  setTabLoading(id, false); setTabTitle(id, "error");
841
- 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>';
900
+ entry.paneEl.innerHTML = '<div class="home-content"><div class="home-center"><p class="sj-error">Service worker failed: ' + err.message + '</p></div></div>';
842
901
  return;
843
902
  }
844
- entry.paneEl.innerHTML = "";
845
- if (!entry.frame) entry.frame = scramjet.createFrame();
846
- entry.paneEl.appendChild(entry.frame.frame);
847
- entry.frame.go(url);
848
- entry.frame.frame.addEventListener("load", function() {
849
- setTabLoading(id, false);
850
- try { const t = entry.frame.frame.contentDocument?.title; if (t) setTabTitle(id, t); } catch(_) {}
851
- }, { once: true });
903
+ await proxyNavigate(entry, url, id);
904
+ // Poll for title up to 8 seconds
852
905
  let attempts = 0;
853
906
  const poll = setInterval(() => {
854
907
  attempts++;
855
- try { const t = entry.frame.frame.contentDocument?.title; if (t) { setTabTitle(id, t); setTabLoading(id, false); clearInterval(poll); } } catch(_) {}
908
+ try {
909
+ let t;
910
+ if (activeProxy === "ultraviolet" && entry.uvFrame) {
911
+ t = entry.uvFrame.contentDocument?.title;
912
+ } else if (entry.frame && entry.frame.frame) {
913
+ t = entry.frame.frame.contentDocument?.title;
914
+ }
915
+ if (t) { setTabTitle(id, t); setTabLoading(id, false); clearInterval(poll); }
916
+ } catch(_) {}
856
917
  if (attempts > 80) { setTabLoading(id, false); clearInterval(poll); }
857
918
  }, 100);
858
919
  }
859
920
 
921
+ /* ══════════════════════════════════════════
922
+ HOME PAGE
923
+ ══════════════════════════════════════════ */
924
+ const QUICK_APPS = [
925
+ { name: "duckduckgo", url: "https://duckduckgo.com", icon: `<img src="icons/DDG-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
926
+ { 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;" />` },
927
+ { 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;" />` },
928
+ { name: "discord", url: "https://discord.com/app", icon: `<img src="icons/DC-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
929
+ { name: "cool math", url: "https://www.coolmathgames.com", icon: `<img src="icons/CMG-Favicon.jpg" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
930
+ { name: "x/twitter", url: "https://x.com", icon: `<img src="icons/X-Favicon.jpg" width="25" height="24" style="border-radius:2px;object-fit:contain;" />` },
931
+ { 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;" />` },
932
+ { name: "music", url: "https://freefy.app/", icon: `<img src="icons/MCTF-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
933
+ { name: "movies", url: "https://www.justwatch.com", icon: `<img src="icons/MP4-Favicon.webp" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
934
+ ];
935
+
936
+ const APPS_REGISTRY = [
937
+ { 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"] },
938
+ { 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"] },
939
+ { 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"] },
940
+ { 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"] },
941
+ { 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"] },
942
+ { name: "X / Twitter", url: "https://x.com", icon: `<img src="icons/X-Favicon.jpg" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Trending topics", tags: ["social","news"] },
943
+ { 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"] },
944
+ { 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", tags: ["ai","tools"] },
945
+ { name: "Now.gg", url: "https://now.gg", icon: `<img src="icons/NGG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Mobile games online", tags: ["games"] },
946
+ { 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: "Free online games", tags: ["games"] },
947
+ { 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"] },
948
+ { name: "DuckDuckGo", url: "https://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"] },
949
+ { 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"] },
950
+ { 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"] },
951
+ { 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"] },
952
+ { name: "Neal.fun", url: "https://neal.fun", icon: `<img src="icons/NDF-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Fun interactive games", tags: ["games","fun"] },
953
+ { 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"] },
954
+ { 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: "Free music streaming", tags: ["music","media"] },
955
+ ];
956
+
860
957
  function buildQuickAppsHTML() {
861
958
  let html = '<div class="quick-apps"><div class="quick-apps-label">quick apps</div><div class="quick-apps-grid">';
862
959
  for (const app of QUICK_APPS) {
863
- 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>';
960
+ 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>`;
864
961
  }
865
962
  return html + '</div></div>';
866
963
  }
@@ -870,29 +967,42 @@
870
967
  '<div class="home-center">' +
871
968
  '<div class="index-title"><span class="tw-text"></span><span class="index-cursor"></span></div>' +
872
969
  '<div class="index-sub tw-sub"> </div>' +
873
- '<form class="sj-form" data-tab="' + id + '" style="width:100%;max-width:560px;display:flex;flex-direction:column;align-items:center;">' +
874
- '<input class="sj-search-engine" value="https://duckduckgo.com/?q=%s" type="hidden" />' +
875
- '<div class="search-row">' +
970
+ '<div class="search-row-wrap" style="width:100%;max-width:560px;display:flex;flex-direction:column;align-items:center;">' +
971
+ '<div class="search-row" data-tabid="' + id + '">' +
876
972
  '<span class="search-prompt">&#62;_</span>' +
877
973
  '<input class="sj-address" type="text" placeholder="search or enter a url" autocomplete="off" spellcheck="false" />' +
878
974
  '<span class="search-enter">enter &crarr;</span>' +
879
- '</div><p class="sj-error"></p></form>' +
975
+ '</div><p class="sj-error"></p></div>' +
880
976
  buildQuickAppsHTML() +
881
977
  '</div>' +
882
978
  '</div>';
883
979
  }
884
980
 
885
981
  function wireHome(paneEl, id) {
886
- const form = paneEl.querySelector(".sj-form");
887
- if (form) {
888
- form.addEventListener("submit", async e => {
982
+ // Use keydown on the input directly — no form tag, avoids SVG foreignObject form issues
983
+ const input = paneEl.querySelector(".sj-address");
984
+ if (input) {
985
+ input.addEventListener("keydown", async e => {
986
+ if (e.key !== "Enter") return;
889
987
  e.preventDefault();
890
- const val = (form.querySelector(".sj-address").value || "").trim();
988
+ const val = (input.value || "").trim();
891
989
  if (!val) return;
892
- const engine = form.querySelector(".sj-search-engine").value || "https://www.google.com/search?q=%s";
893
- await navigateTab(id, search(val, engine));
990
+ // DuckDuckGo search — use direct search URL that always returns results
991
+ const engine = "https://duckduckgo.com/?q=%s&ia=web";
992
+ if (typeof search === "function") {
993
+ await navigateTab(id, search(val, engine));
994
+ } else {
995
+ // Fallback if search.js not loaded
996
+ let url;
997
+ try { url = new URL(val).toString(); } catch(_) {
998
+ try { const u = new URL("https://" + val); if (u.hostname.includes(".")) url = u.toString(); } catch(_) {}
999
+ }
1000
+ if (!url) url = "https://duckduckgo.com/?q=" + encodeURIComponent(val) + "&ia=web";
1001
+ await navigateTab(id, url);
1002
+ }
894
1003
  });
895
1004
  }
1005
+
896
1006
  paneEl.querySelectorAll(".quick-app").forEach(el => {
897
1007
  el.addEventListener("click", () => navigateTab(id, el.dataset.url));
898
1008
  });
@@ -909,18 +1019,22 @@
909
1019
  let fontIndex = 0;
910
1020
 
911
1021
  function runCycle() {
1022
+ // Bail if the tab was closed
1023
+ if (!document.contains(paneEl)) return;
912
1024
  const titleEl = paneEl.querySelector(".index-title");
913
1025
  if (titleEl) titleEl.style.fontFamily = fonts[fontIndex % fonts.length];
914
1026
  fontIndex++;
915
1027
  if (twSub) twSub.classList.remove("visible");
916
1028
  let i = 0;
917
1029
  function type() {
1030
+ if (!document.contains(paneEl)) return;
918
1031
  twEl.textContent = word.slice(0, i);
919
1032
  if (i < word.length) { i++; setTimeout(type, 80 + Math.random() * 70); }
920
1033
  else { if (twSub) twSub.classList.add("visible"); setTimeout(deleteText, 2200); }
921
1034
  }
922
1035
  let j = word.length;
923
1036
  function deleteText() {
1037
+ if (!document.contains(paneEl)) return;
924
1038
  if (twSub) twSub.classList.remove("visible");
925
1039
  twEl.textContent = word.slice(0, j);
926
1040
  if (j > 0) { j--; setTimeout(deleteText, 55 + Math.random() * 40); }
@@ -932,10 +1046,36 @@
932
1046
  }
933
1047
 
934
1048
  newTabBtn.addEventListener("click", () => createTab());
1049
+
1050
+ /* ══════════════════════════════════════════
1051
+ RESTORE SETTINGS (after createTab so updateQuickAppColors works)
1052
+ ══════════════════════════════════════════ */
1053
+ function restoreSettings() {
1054
+ // Restore cloak
1055
+ const savedCloak = localStorage.getItem("cloak");
1056
+ if (savedCloak) {
1057
+ try {
1058
+ const c = JSON.parse(savedCloak);
1059
+ currentCloak = c;
1060
+ applyCloak(c.title, c.favicon);
1061
+ document.querySelectorAll(".cloak-option").forEach(o => {
1062
+ o.classList.toggle("selected", o.dataset.cloak === c.cloak);
1063
+ });
1064
+ } catch(_) {}
1065
+ }
1066
+ // Restore proxy engine
1067
+ saveProxyEngine(activeProxy);
1068
+ // Restore theme
1069
+ const savedTheme = localStorage.getItem("theme") || "default";
1070
+ applyTheme(savedTheme);
1071
+ }
1072
+
1073
+ // Create first tab BEFORE restoreSettings so icon color patch works
935
1074
  createTab();
1075
+ restoreSettings();
936
1076
 
937
1077
  /* ══════════════════════════════════════════
938
- GAMES TAB (unchanged)
1078
+ GAMES TAB
939
1079
  ══════════════════════════════════════════ */
940
1080
  const gamesBtn = document.getElementById("games-btn");
941
1081
  let gamesTabId = null;
@@ -944,9 +1084,9 @@
944
1084
  async function loadGamesRegistry() {
945
1085
  try {
946
1086
  const res = await fetch("games/games.json");
947
- if (!res.ok) throw new Error();
1087
+ if (!res.ok) throw new Error("HTTP " + res.status);
948
1088
  gamesRegistry = await res.json();
949
- } catch(_) { gamesRegistry = []; }
1089
+ } catch(e) { gamesRegistry = []; console.warn("Failed to load games.json:", e); }
950
1090
  }
951
1091
 
952
1092
  function getAllTags(registry) {
@@ -980,7 +1120,7 @@
980
1120
  renderCards(entry.paneEl, gamesRegistry);
981
1121
  const searchInput = entry.paneEl.querySelector("#games-search-input");
982
1122
  const searchClear = entry.paneEl.querySelector("#games-search-clear");
983
- let activeTag = "all";
1123
+ let activeTag = "all";
984
1124
  function applyFilters() {
985
1125
  const q = searchInput.value.trim().toLowerCase();
986
1126
  searchClear.classList.toggle("visible", q.length > 0);
@@ -1003,22 +1143,31 @@
1003
1143
  applyFilters();
1004
1144
  });
1005
1145
  }
1006
- entry.paneEl.querySelector("#games-close-btn").addEventListener("click", () => { closeTab(tabId); gamesTabId=null; });
1146
+ entry.paneEl.querySelector("#games-close-btn").addEventListener("click", () => {
1147
+ closeTab(tabId); gamesTabId = null;
1148
+ gamesBtn.classList.remove("active");
1149
+ });
1007
1150
  }
1008
1151
 
1009
1152
  function renderCards(paneEl, list) {
1010
- const grid = paneEl.querySelector("#games-grid"); if (!grid) return;
1011
- 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; }
1012
- grid.innerHTML = list.map(g => {
1013
- const tagsHTML = (g.tags||[]).length ? `<div class="game-card-tags">${(g.tags).map(t=>`<span class="game-card-tag">${t}</span>`).join("")}</div>` : "";
1014
- const iconSrc = g.icon && g.icon.startsWith("/") ? g.icon.replace(/^\/+/, '') : g.icon;
1015
- const iconHTML = (iconSrc && (iconSrc.includes("/") || iconSrc.includes(".")))
1016
- ? `<img src="${iconSrc}" style="width:2em;height:2em;object-fit:contain;border-radius:4px;" onerror="this.outerHTML='🎮'" />`
1017
- : (iconSrc || "🎮");
1018
- 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>`;
1019
- }).join("");
1020
- grid.querySelectorAll(".game-card").forEach(card => { card.addEventListener("click", () => openGameModal(card.dataset.file, card.dataset.name)); });
1021
- }
1153
+ const grid = paneEl.querySelector("#games-grid"); if (!grid) return;
1154
+ if (list.length === 0) {
1155
+ 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>';
1156
+ return;
1157
+ }
1158
+ grid.innerHTML = list.map(g => {
1159
+ const tagsHTML = (g.tags||[]).length ? `<div class="game-card-tags">${(g.tags).map(t=>`<span class="game-card-tag">${t}</span>`).join("")}</div>` : "";
1160
+ const iconSrc = g.icon && g.icon.startsWith("/") ? g.icon.replace(/^\/+/, '') : g.icon;
1161
+ const iconHTML = (iconSrc && (iconSrc.includes("/") || iconSrc.includes(".")))
1162
+ ? `<img src="${iconSrc}" style="width:2em;height:2em;object-fit:contain;border-radius:4px;" onerror="this.outerHTML='🎮'" />`
1163
+ : (iconSrc || "🎮");
1164
+ 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>`;
1165
+ }).join("");
1166
+ grid.querySelectorAll(".game-card").forEach(card => {
1167
+ card.addEventListener("click", () => openGameModal(card.dataset.file, card.dataset.name));
1168
+ });
1169
+ }
1170
+
1022
1171
  const gameModal = document.getElementById("game-modal");
1023
1172
  const gmName = document.getElementById("gm-name");
1024
1173
  const gmFile = document.getElementById("gm-file");
@@ -1027,14 +1176,14 @@
1027
1176
  const gmFullscreen = document.getElementById("gm-fullscreen");
1028
1177
 
1029
1178
  function openGameModal(file, name) {
1030
- if (file === "gamesuggestions.html") {
1031
- window.open("https://forms.gle/aSBH2kMVEUwmhiRp6", "_blank");
1032
- return;
1033
- }
1034
- gmName.textContent = name; gmFile.textContent = file;
1035
- gmIframe.src = "games/" + file;
1036
- gameModal.classList.add("open");
1037
- }
1179
+ if (file === "gamesuggestion.html" || file === "gamesuggestions.html") {
1180
+ window.open("https://forms.gle/aSBH2kMVEUwmhiRp6", "_blank");
1181
+ return;
1182
+ }
1183
+ gmName.textContent = name; gmFile.textContent = file;
1184
+ gmIframe.src = "games/" + file;
1185
+ gameModal.classList.add("open");
1186
+ }
1038
1187
  function closeGameModal() { gameModal.classList.remove("open"); gmIframe.src="about:blank"; }
1039
1188
  gmClose.addEventListener("click", closeGameModal);
1040
1189
  document.addEventListener("keydown", e => { if (e.key==="Escape" && gameModal.classList.contains("open")) closeGameModal(); });
@@ -1044,7 +1193,11 @@
1044
1193
  });
1045
1194
 
1046
1195
  async function openGamesTab() {
1047
- if (gamesTabId && tabs.has(gamesTabId)) { activateTab(gamesTabId); gamesBtn.classList.add("active"); return; }
1196
+ if (gamesTabId && tabs.has(gamesTabId)) {
1197
+ activateTab(gamesTabId);
1198
+ gamesBtn.classList.add("active");
1199
+ return;
1200
+ }
1048
1201
  await loadGamesRegistry();
1049
1202
  gamesTabId = createTab("🎮 games");
1050
1203
  setTabTitle(gamesTabId, "🎮 games");
@@ -1054,7 +1207,7 @@
1054
1207
  gamesBtn.addEventListener("click", openGamesTab);
1055
1208
 
1056
1209
  /* ══════════════════════════════════════════
1057
- APPS TAB (unchanged)
1210
+ APPS TAB
1058
1211
  ══════════════════════════════════════════ */
1059
1212
  const appsBtn = document.getElementById("apps-btn");
1060
1213
  let appsTabId = null;
@@ -1090,7 +1243,7 @@
1090
1243
  renderAppCards(entry.paneEl, APPS_REGISTRY, tabId);
1091
1244
  const searchInput = entry.paneEl.querySelector("#apps-search-input");
1092
1245
  const searchClear = entry.paneEl.querySelector("#apps-search-clear");
1093
- let activeTag = "all";
1246
+ let activeTag = "all";
1094
1247
  function applyFilters() {
1095
1248
  const q = searchInput.value.trim().toLowerCase();
1096
1249
  searchClear.classList.toggle("visible", q.length > 0);
@@ -1113,12 +1266,14 @@
1113
1266
  applyFilters();
1114
1267
  });
1115
1268
  }
1116
- entry.paneEl.querySelector("#apps-close-btn").addEventListener("click", () => { closeTab(tabId); appsTabId=null; appsBtn.classList.remove("active"); });
1269
+ entry.paneEl.querySelector("#apps-close-btn").addEventListener("click", () => {
1270
+ closeTab(tabId); appsTabId = null; appsBtn.classList.remove("active");
1271
+ });
1117
1272
  }
1118
1273
 
1119
1274
  function renderAppCards(paneEl, list, tabId) {
1120
1275
  const grid = paneEl.querySelector("#apps-grid"); if (!grid) return;
1121
- 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; }
1276
+ if (list.length===0) { grid.innerHTML='<div class="games-noresults">no apps match your search.</div>'; return; }
1122
1277
  grid.innerHTML = list.map(a => {
1123
1278
  const tagsHTML = (a.tags||[]).length ? `<div class="game-card-tags">${(a.tags).map(t=>`<span class="game-card-tag">${t}</span>`).join("")}</div>` : "";
1124
1279
  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>`;
@@ -1138,4 +1293,4 @@
1138
1293
  appsBtn.addEventListener("click", openAppsTab);
1139
1294
  </script>
1140
1295
  </body>
1141
- </html>
1296
+ </html>