4sp-dv 1.0.41 → 1.0.43

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.
@@ -841,7 +841,7 @@
841
841
  }
842
842
 
843
843
  // --- Game Viewer Logic ---
844
- function openZone(game) {
844
+ async function openZone(game) {
845
845
  if (!game || !game.url) return;
846
846
  updateURL(categories[currentCategoryIndex], game.id || null);
847
847
 
@@ -851,6 +851,35 @@
851
851
  const downloadBtn = document.getElementById('downloadBtnZone');
852
852
  const controls = zoneViewer.querySelector('.zone-controls');
853
853
 
854
+ // --- Custom 404 Page Helper ---
855
+ const show404 = (errorMsg = "Game content unavailable.") => {
856
+ const doc = zoneFrame.contentWindow.document;
857
+ doc.open();
858
+ doc.write(`
859
+ <!DOCTYPE html>
860
+ <html>
861
+ <head>
862
+ <link href="https://fonts.googleapis.com/css2?family=Geist:wght@100..900&display=swap" rel="stylesheet">
863
+ <style>
864
+ body { background: #000; color: #fff; font-family: 'Geist', sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; text-align: center; }
865
+ h1 { font-size: 4rem; margin: 0; color: #4f46e5; }
866
+ p { color: #888; font-size: 1.2rem; max-width: 400px; margin-top: 10px; }
867
+ .btn { margin-top: 30px; padding: 10px 25px; border: 1px solid #333; border-radius: 12px; color: #fff; cursor: pointer; background: #111; transition: all 0.2s; }
868
+ .btn:hover { border-color: #4f46e5; background: #4f46e51a; }
869
+ </style>
870
+ </head>
871
+ <body>
872
+ <h1>404</h1>
873
+ <p><strong>${game.name}</strong> could not be loaded.<br><span style="font-size: 0.9rem; opacity: 0.7;">${errorMsg}</span></p>
874
+ <div class="btn" onclick="window.parent.closeZoneViewer()">Return to Hub</div>
875
+ </body>
876
+ </html>
877
+ `);
878
+ doc.close();
879
+ zoneViewer.style.display = "flex";
880
+ zoneViewer.classList.add('active', 'animate-fade-in');
881
+ };
882
+
854
883
  // Setup Download Button (Specific to Eaglercraft)
855
884
  if (game.baseGameId === 'other-eaglercraft' || game.id === 'other-eaglercraft') {
856
885
  downloadBtn.href = game.url;
@@ -897,12 +926,19 @@
897
926
  const isStandardURLGame = game.category === 'StrongdogXP' || game.category === 'Others' || game.category === 'GN-Math';
898
927
 
899
928
  if (isStandardURLGame) {
900
- zoneFrame.src = game.url;
901
-
902
- // SHOW WITH ANIMATION
903
- zoneViewer.style.display = "flex";
904
- zoneViewer.classList.remove('animate-fade-out');
905
- zoneViewer.classList.add('active', 'animate-fade-in');
929
+ // Try fetching to see if it exists (Fixes the jsdelivr redirect bug)
930
+ try {
931
+ const check = await fetch(game.url, { method: 'HEAD' });
932
+ if (!check.ok) throw new Error("File not found");
933
+ zoneFrame.src = game.url;
934
+
935
+ // SHOW WITH ANIMATION
936
+ zoneViewer.style.display = "flex";
937
+ zoneViewer.classList.remove('animate-fade-out');
938
+ zoneViewer.classList.add('active', 'animate-fade-in');
939
+ } catch (e) {
940
+ show404("The game source is broken or blocked.");
941
+ }
906
942
  } else {
907
943
  fetch(`${game.url}?t=${Date.now()}`)
908
944
  .then(response => {
@@ -921,12 +957,7 @@
921
957
  zoneViewer.classList.add('active', 'animate-fade-in');
922
958
  })
923
959
  .catch(error => {
924
- console.error(`Failed to load game "${game.name}": ${error.message}`);
925
- zoneFrame.src = game.url;
926
-
927
- zoneViewer.style.display = "flex";
928
- zoneViewer.classList.remove('animate-fade-out');
929
- zoneViewer.classList.add('active', 'animate-fade-in');
960
+ show404(error.message);
930
961
  });
931
962
  }
932
963
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "4sp-dv",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/v5-4simpleproblems/v5-4simpleproblems-dv#readme",