|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta charset="UTF-8"> |
| 5 | + <title>Bloxcraft UBG - Games</title> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 7 | + <link id="favicon" rel="shortcut icon" type="image/png" href="/bloxcraft.png"> |
| 8 | + <link rel="stylesheet" href="/app-viewer/app-viewer-default.css"> |
| 9 | + <script async src="https://www.googletagmanager.com/gtag/js?id=G-W0KXN0103E"></script> |
| 10 | + <script> |
| 11 | + window.dataLayer = window.dataLayer || []; |
| 12 | + function gtag(){dataLayer.push(arguments);} |
| 13 | + gtag('js', new Date()); |
| 14 | + gtag('config', 'G-W0KXN0103E'); |
| 15 | + </script> |
| 16 | + |
| 17 | + <script> |
| 18 | + (function(w,d,s,l,i){ |
| 19 | + w[l]=w[l]||[]; |
| 20 | + w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'}); |
| 21 | + var f=d.getElementsByTagName(s)[0], |
| 22 | + j=d.createElement(s), |
| 23 | + dl=l!='dataLayer'?'&l='+l:''; |
| 24 | + j.async=true; |
| 25 | + j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl; |
| 26 | + f.parentNode.insertBefore(j,f); |
| 27 | + })(window,document,'script','dataLayer','GTM-NQM8XR48'); |
| 28 | + </script> |
| 29 | +</head> |
| 30 | + |
| 31 | +<body> |
| 32 | +<div id="viewerBar"> |
| 33 | + <p id="viewerTitle">Loading...</p> |
| 34 | + <div id="Btn-Group"> |
| 35 | + <a class="bloxy-blue-btn bloxy-btn" href="/games">Close</a> |
| 36 | + <a class="bloxy-blue-btn bloxy-btn" id="closeViewer">Google</a> |
| 37 | + <a class="bloxy-blue-btn bloxy-btn" id="openNewTab">Play In New Tab</a> |
| 38 | + </div> |
| 39 | +</div> |
| 40 | + |
| 41 | +<iframe id="viewerFrame"></iframe> |
| 42 | + |
| 43 | +<script> |
| 44 | +const params = new URLSearchParams(window.location.search); |
| 45 | +const view = params.get("view"); |
| 46 | + |
| 47 | +const BASE = "https://cdn.jsdelivr.net/gh/carbonicality/ChickenKingsVault@main/gamefiles/"; |
| 48 | +const JSON_URL = "https://cdn.jsdelivr.net/gh/carbonicality/ChickenKingsVault@main/games.json"; |
| 49 | + |
| 50 | +const viewerFrame = document.getElementById("viewerFrame"); |
| 51 | +const viewerTitle = document.getElementById("viewerTitle"); |
| 52 | +const openNewTab = document.getElementById("openNewTab"); |
| 53 | + |
| 54 | +function show404(){ |
| 55 | + viewerFrame.srcdoc = "<h1 style='color:white;background:black;height:100vh;display:flex;align-items:center;justify-content:center;'>404</h1>"; |
| 56 | +} |
| 57 | + |
| 58 | +if(!view){ |
| 59 | + show404(); |
| 60 | +} else { |
| 61 | + |
| 62 | + fetch(JSON_URL) |
| 63 | + .then(r=>r.json()) |
| 64 | + .then(data=>{ |
| 65 | + const game = data.find(g => g.html === view); |
| 66 | + if(!game) throw new Error(); |
| 67 | + |
| 68 | + const fullUrl = BASE + game.html; |
| 69 | + viewerTitle.textContent = game.name; |
| 70 | + |
| 71 | + fetch(fullUrl) |
| 72 | + .then(r=>r.text()) |
| 73 | + .then(html=>{ |
| 74 | + viewerFrame.srcdoc = html; |
| 75 | + }); |
| 76 | + |
| 77 | + openNewTab.onclick = async () => { |
| 78 | + const html = await fetch(fullUrl).then(r=>r.text()); |
| 79 | + const tab = window.open("about:blank"); |
| 80 | + tab.document.write(html); |
| 81 | + }; |
| 82 | + |
| 83 | + }) |
| 84 | + .catch(show404); |
| 85 | +} |
| 86 | + |
| 87 | +document.getElementById("closeViewer").onclick = ()=>{ |
| 88 | + window.top.location.href = "https://google.com/"; |
| 89 | +}; |
| 90 | +</script> |
| 91 | +</body> |
| 92 | +</html> |
0 commit comments