UNPKG

krying

Version:

krying — games hub, AI, movies, and tools

629 lines (508 loc) • 20.8 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>krying proxy</title> <script src="/sail/baremux/index.js"></script> <script src="/sail/scram/scramjet.all.js"></script> <style> * { box-sizing: border-box; } :root { --bg: #000000; --toolbar: #0d0d0d; --toolbar2: #111111; --tab: #0f0f0f; --tab-hover: #1b1b1b; --border: #1f1f1f; --text: #ffffff; --muted: #8a8a8a; --active: #1c1c1c; } body { margin: 0; background: black; color: white; font-family: Arial, Helvetica, sans-serif; height: 100vh; overflow: hidden; display: flex; flex-direction: column; } .tab-bar { height: 36px; background: var(--toolbar); display: flex; align-items: flex-end; padding: 0 8px; gap: 6px; border-bottom: 1px solid var(--border); } .tab { height: 34px; min-width: 190px; max-width: 220px; background: var(--tab); border-radius: 10px 10px 0 0; display: flex; align-items: center; gap: 10px; padding: 0 12px; cursor: pointer; color: #cfcfcf; user-select: none; transition: .15s; } .tab:hover { background: var(--tab-hover); } .tab.active { background: #111111; } .tab-icon { width: 14px; height: 14px; opacity: .9; } .tab-icon svg { width: 100%; height: 100%; fill: white; } .tab-title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; } .tab-close { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: .15s; } .tab-close:hover { background: rgba(255, 255, 255, .12); } .new-tab-btn { width: 34px; height: 34px; border: none; background: transparent; color: white; font-size: 22px; cursor: pointer; border-radius: 8px; transition: .15s; } .new-tab-btn:hover { background: #1a1a1a; } .navbar { height: 52px; background: black; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding: 0 12px; } .nav-btn { width: 32px; height: 32px; border: none; background: transparent; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: .15s; } .nav-btn:hover { background: #1d1d1d; } .nav-btn svg { width: 16px; height: 16px; fill: white; } .address-bar { flex: 1; height: 34px; background: #0a0a0a; border: 1px solid #1f1f1f; border-radius: 8px; display: flex; align-items: center; padding: 0 12px; gap: 10px; } .lock-icon { width: 14px; height: 14px; opacity: .9; } .lock-icon svg { width: 100%; height: 100%; fill: #3ddc84; } #bar { flex: 1; background: transparent; border: none; outline: none; color: white; font-size: 14px; } .bookmarks-bar { height: 30px; background: black; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 10px; gap: 10px; } .bookmark { color: #cfcfcf; text-decoration: none; font-size: 13px; padding: 4px 8px; border-radius: 6px; transition: .15s; } .bookmark:hover { background: #1b1b1b; } #viewport-container { flex: 1; position: relative; background: black; } iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; display: none; background: black; } iframe.active { display: block; } .settings-panel { position: fixed; top: 50px; right: 10px; width: 320px; background: #111111; border: 1px solid #242424; border-radius: 14px; padding: 16px; display: none; z-index: 9999; } .settings-panel.open { display: block; } .settings-title { font-size: 18px; font-weight: bold; margin-bottom: 16px; } .settings-label { font-size: 13px; color: #b5b5b5; margin-bottom: 8px; display: block; } .settings-select, .settings-input { width: 100%; height: 42px; background: #0b0b0b; border: 1px solid #262626; border-radius: 10px; color: white; padding: 0 12px; outline: none; margin-bottom: 14px; } #custom-ws-group { display: none; } .settings-save { width: 100%; height: 42px; border: none; background: white; color: black; font-weight: bold; border-radius: 10px; cursor: pointer; } .settings-save:hover { opacity: .9; } </style> </head> <body> <div class="tab-bar" id="tab-bar"> <button class="new-tab-btn" onclick="addTab()">+</button> </div> <div class="navbar"> <button class="nav-btn" onclick="goBack()"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"> <path d="M73.4 297.4C60.9 309.9 60.9 330.2 73.4 342.7L233.4 502.7C245.9 515.2 266.2 515.2 278.7 502.7C291.2 490.2 291.2 469.9 278.7 457.4L173.3 352L544 352C561.7 352 576 337.7 576 320C576 302.3 561.7 288 544 288L173.3 288L278.7 182.6C291.2 170.1 291.2 149.8 278.7 137.3C266.2 124.8 245.9 124.8 233.4 137.3L73.4 297.3z" /> </svg> </button> <button class="nav-btn" onclick="goForward()" style="transform: rotate(180deg);"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"> <path d="M73.4 297.4C60.9 309.9 60.9 330.2 73.4 342.7L233.4 502.7C245.9 515.2 266.2 515.2 278.7 502.7C291.2 490.2 291.2 469.9 278.7 457.4L173.3 352L544 352C561.7 352 576 337.7 576 320C576 302.3 561.7 288 544 288L173.3 288L278.7 182.6C291.2 170.1 291.2 149.8 278.7 137.3C266.2 124.8 245.9 124.8 233.4 137.3L73.4 297.3z" /> </svg> </button> <button class="nav-btn" onclick="refreshTab()"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"> <path d="M129.9 292.5C143.2 199.5 223.3 128 320 128C373 128 421 149.5 455.8 184.2C456 184.4 456.2 184.6 456.4 184.8L464 192L416.1 192C398.4 192 384.1 206.3 384.1 224C384.1 241.7 398.4 256 416.1 256L544.1 256C561.8 256 576.1 241.7 576.1 224L576.1 96C576.1 78.3 561.8 64 544.1 64C526.4 64 512.1 78.3 512.1 96L512.1 149.4L500.8 138.7C454.5 92.6 390.5 64 320 64C191 64 84.3 159.4 66.6 283.5C64.1 301 76.2 317.2 93.7 319.7C111.2 322.2 127.4 310 129.9 292.6zM573.4 356.5C575.9 339 563.7 322.8 546.3 320.3C528.9 317.8 512.6 330 510.1 347.4C496.8 440.4 416.7 511.9 320 511.9C267 511.9 219 490.4 184.2 455.7C184 455.5 183.8 455.3 183.6 455.1L176 447.9L223.9 447.9C241.6 447.9 255.9 433.6 255.9 415.9C255.9 398.2 241.6 383.9 223.9 383.9L96 384C87.5 384 79.3 387.4 73.3 393.5C67.3 399.6 63.9 407.7 64 416.3L65 543.3C65.1 561 79.6 575.2 97.3 575C115 574.8 129.2 560.4 129 542.7L128.6 491.2L139.3 501.3C185.6 547.4 249.5 576 320 576C449 576 555.7 480.6 573.4 356.5z" /> </svg> </button> <div class="address-bar"> <div class="lock-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"> <path d="M144 144V112C144 76.7 172.7 48 208 48H240C275.3 48 304 76.7 304 112V144H144zM96 144H80C53.5 144 32 165.5 32 192V432C32 458.5 53.5 480 80 480H368C394.5 480 416 458.5 416 432V192C416 165.5 394.5 144 368 144H352V112C352 50.1 301.9 0 240 0H208C146.1 0 96 50.1 96 112V144z" /> </svg> </div> <input type="text" id="bar"> </div> <button class="nav-btn" onclick="toggleSettings()"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"> <path d="M259.173.5C262.1 58.7 275.2 48 290.4 48L350.2 48C365.4 48 378.5 58.7 381.5 73.5L396 143.5C410.1 149.5 423.3 157.2 435.3 166.3L503.1 143.8C517.5 139 533.3 145 540.9 158.2L570.8 210C578.4 223.2 575.7 239.8 564.3 249.9L511 297.3C511.9 304.7 512.3 312.3 512.3 320C512.3 327.7 511.8 335.3 511 342.7L564.4 390.2C575.8 400.3 578.4 417 570.9 430.1L541 481.9C533.4 495 517.6 501.1 503.2 496.3L435.4 473.8C423.3 482.9 410.1 490.5 396.1 496.6L381.7 566.5C378.6 581.4 365.5 592 350.4 592L290.6 592C275.4 592 262.3 581.3 259.3 566.5L244.9 496.6C230.8 490.6 217.7 482.9 205.6 473.8L137.5 496.3C123.1 501.1 107.3 495.1 99.7 481.9L69.8 430.1C62.2 416.9 64.9 400.3 76.3 390.2L129.7 342.7C128.8 335.3 128.4 327.7 128.4 320C128.4 312.3 128.9 304.7 129.7 297.3L76.3 249.8C64.9 239.7 62.3 223 69.8 209.9L99.7 158.1C107.3 144.9 123.1 138.9 137.5 143.7L205.3 166.2C217.4 157.1 230.6 149.5 244.6 143.4L259.1 73.5zM320.3 400C364.5 399.8 400.2 363.9 400 319.7C399.8 275.5 363.9 239.8 319.7 240C275.5 240.2 239.8 276.1 240 320.3C240.2 364.5 276.1 400.2 320.3 400z" /> </svg> </button> </div> <div class="bookmarks-bar"> <a class="bookmark" href="javascript:void(0)" onclick="quickNav('https://google.com')">Google</a> <a class="bookmark" href="javascript:void(0)" onclick="quickNav('https://youtube.com')">YouTube</a> <a class="bookmark" href="javascript:void(0)" onclick="quickNav('https://discord.com/app')">Discord</a> <a class="bookmark" href="javascript:void(0)" onclick="quickNav('https://github.com')">GitHub</a> </div> <div id="viewport-container"></div> <div class="settings-panel" id="settings-panel"> <div class="settings-title">Settings</div> <label class="settings-label">Wisp Server</label> <select id="ws-select" class="settings-select"> <option value="default">wss://wisp.classroom.lat/</option> <option value="custom">Custom</option> </select> <div id="custom-ws-group"> <label class="settings-label">Custom Wisp</label> <input type="text" id="custom-ws" class="settings-input" placeholder="wss://example.com/wisp/"> </div> <button class="settings-save" onclick="saveSettings()">Save Settings</button> </div> <script> const tabBar = document.getElementById("tab-bar"); const bar = document.getElementById("bar"); const viewportContainer = document.getElementById("viewport-container"); const wsSelect = document.getElementById("ws-select"); const customWsGroup = document.getElementById("custom-ws-group"); const customWsInput = document.getElementById("custom-ws"); let isFocused = false; let tabs = []; let activeTabId = null; bar.addEventListener("focus", () => { isFocused = true; }); bar.addEventListener("blur", () => { isFocused = false; }); const defaultWs = "wss://wisp.classroom.lat/"; let currentWs = localStorage.getItem("proxy-ws") || defaultWs; navigator.serviceWorker.register("/sail/sw.js"); const connection = new BareMux.BareMuxConnection("/sail/baremux/worker.js"); async function applyTransport() { await connection.setTransport("/sail/libcurl/index.mjs", [ { websocket: currentWs } ]); } applyTransport(); const { ScramjetController } = $scramjetLoadController(); const scramjet = new ScramjetController({ files: { all: "/sail/scram/scramjet.all.js", wasm: "/sail/scram/scramjet.wasm.wasm", sync: "/sail/scram/scramjet.sync.js" }, prefix: "/sail/go/" }); scramjet.init(); function decodeProxiedUrl(u) { if (!u) return ""; try { if (u.includes("/sail/go/")) { let part = u.split("/sail/go/")[1] || ""; part = decodeURIComponent(part); return part; } return u; } catch { return u; } } function updateCustomWsVisibility() { customWsGroup.style.display = wsSelect.value === "custom" ? "block" : "none"; } wsSelect.addEventListener("change", updateCustomWsVisibility); function toggleSettings() { document.getElementById("settings-panel").classList.toggle("open"); } function saveSettings() { if (wsSelect.value === "custom") { const custom = customWsInput.value.trim(); if (!custom) return; currentWs = custom; } else { currentWs = defaultWs; } localStorage.setItem("proxy-ws", currentWs); applyTransport(); toggleSettings(); } function getNewTabPage() { return scramjet.encodeUrl("https://google.com"); } function addTab(url = "krying://newtab") { const id = "tab-" + crypto.randomUUID(); const tabObj = { id, title: "New Tab", url }; tabs.push(tabObj); const tabEl = document.createElement("div"); tabEl.className = "tab"; tabEl.id = "btn-" + id; tabEl.innerHTML = ` <div class="tab-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"> <path d="M320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64z"/> </svg> </div> <span class="tab-title">New Tab</span> <div class="tab-close">×</div> `; tabEl.onclick = () => switchTab(id); tabEl.querySelector(".tab-close").onclick = (e) => closeTab(e, id); tabBar.insertBefore(tabEl, document.querySelector(".new-tab-btn")); const iframe = document.createElement("iframe"); iframe.id = "frame-" + id; if (url === "krying://newtab") { iframe.src = getNewTabPage(); } else { iframe.src = scramjet.encodeUrl(formatUrl(url)); } iframe.addEventListener("load", () => updateTabTitle(id)); viewportContainer.appendChild(iframe); switchTab(id); } function switchTab(id) { activeTabId = id; tabs.forEach(tab => { const btn = document.getElementById("btn-" + tab.id); const frame = document.getElementById("frame-" + tab.id); const active = tab.id === id; btn.classList.toggle("active", active); frame.classList.toggle("active", active); if (active) { const f = document.getElementById("frame-" + tab.id); bar.value = decodeProxiedUrl(f?.src || tab.url); } }); } function closeTab(event, id) { event.stopPropagation(); if (tabs.length === 1) return; const index = tabs.findIndex(t => t.id === id); document.getElementById("btn-" + id)?.remove(); document.getElementById("frame-" + id)?.remove(); tabs.splice(index, 1); if (activeTabId === id) { const next = tabs[index] || tabs[index - 1]; if (next) switchTab(next.id); } } function formatUrl(url) { if (!url) return ""; if (!url.startsWith("http://") && !url.startsWith("https://")) { if (url.includes(".")) return "https://" + url; return "https://duckduckgo.com/?q=" + encodeURIComponent(url); } return url; } function nav() { if (!activeTabId) return; const value = bar.value.trim(); if (!value) return; const formatted = value === "krying://newtab" ? "krying://newtab" : formatUrl(value); const tab = tabs.find(t => t.id === activeTabId); tab.url = formatted; const frame = document.getElementById("frame-" + activeTabId); if (formatted === "krying://newtab") { frame.src = getNewTabPage(); } else { frame.src = scramjet.encodeUrl(formatted); } bar.value = decodeProxiedUrl(frame.src); updateTabTitle(activeTabId, formatted); } function updateTabTitle(id, fallback = "Loading...") { const tab = tabs.find(t => t.id === id); let title = fallback; if (tab.url === "krying://newtab") { title = "krying - New Tab"; } else { try { title = new URL(tab.url).hostname; } catch { title = fallback; } } document.querySelector(`#btn-${id} .tab-title`).textContent = title; } function goBack() { if (!activeTabId) return; document.getElementById("frame-" + activeTabId)?.contentWindow?.history?.back(); } function goForward() { if (!activeTabId) return; document.getElementById("frame-" + activeTabId)?.contentWindow?.history?.forward(); } function refreshTab() { if (!activeTabId) return; document.getElementById("frame-" + activeTabId)?.contentWindow?.location?.reload(); } function quickNav(url) { bar.value = url; nav(); } bar.addEventListener("keydown", (e) => { if (e.key === "Enter") nav(); }); setInterval(() => { if (!activeTabId || isFocused) return; const frame = document.getElementById("frame-" + activeTabId); if (!frame) return; const decoded = decodeProxiedUrl(frame.src); if (bar.value !== decoded) { bar.value = decoded; } }, 500); window.addEventListener("load", () => { updateCustomWsVisibility(); addTab("krying://newtab"); }); </script> </body> </html>