const { ScramjetController } = $scramjetLoadController(); const scramjet = new ScramjetController({ files: { wasm: "/scram/scramjet.wasm.wasm", all: "/scram/scramjet.all.js", sync: "/scram/scramjet.sync.js", }, flags: { rewriterLogs: false, naiiveRewriter: false, scramitize: false, }, siteFlags: { "https://www.google.com/(search|sorry).*": { naiiveRewriter: true, }, "https://worker-playground.glitch.me/.*": { serviceworkers: true, }, }, }); scramjet.init(); navigator.serviceWorker.register("./sw.js"); const connection = new BareMux.BareMuxConnection("/baremux/worker.js"); const flex = css` display: flex; `; const col = css` flex-direction: column; `; connection.setTransport(store.transport, [{ wisp: store.wispurl }]); function Config() { this.css = ` transition: opacity 0.4s ease; :modal[open] { animation: fade 0.4s ease normal; } :modal::backdrop { backdrop-filter: blur(3px); } .buttons { gap: 0.5em; } .buttons button { border: 1px solid #4c8bf5; background-color: #313131; border-radius: 0.75em; color: #fff; padding: 0.45em; } .input_row input { background-color: rgb(18, 18, 18); border: 2px solid rgb(49, 49, 49); border-radius: 0.75em; color: #fff; outline: none; padding: 0.45em; } .input_row { margin-bottom: 0.5em; margin-top: 0.5em; } .input_row input { flex-grow: 1; } .centered { justify-content: center; align-items: center; } `; function handleModalClose(modal) { modal.style.opacity = 0; setTimeout(() => { modal.close(); modal.style.opacity = 1; }, 250); } return html`
${use(store.transport)}
`; } function BrowserApp() { this.css = ` width: 100%; height: 100%; color: #e0def4; display: flex; flex-direction: column; padding: 0.5em; padding-top: 0; box-sizing: border-box; a { color: #e0def4; } input, button { font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif; } .version { } h1 { font-family: "Inter Tight", "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif; margin-bottom: 0; } iframe { background-color: #fff; border: none; border-radius: 0.3em; flex: 1; width: 100%; } input.bar { font-family: "Inter"; padding: 0.1em; padding-left: 0.3em; border: none; outline: none; color: #fff; height: 1.5em; border-radius: 0.3em; flex: 1; background-color: #121212; border: 1px solid #313131; } .input_row > label { font-size: 0.7rem; color: gray; } p { margin: 0; margin-top: 0.2em; } .nav { padding-top: 0.3em; padding-bottom: 0.3em; gap: 0.3em; } spacer { margin-left: 10em; } .nav button { color: #fff; outline: none; border: none; border-radius: 0.30em; background-color: #121212; border: 1px solid #313131; } `; this.url = store.url; const frame = scramjet.createFrame(); frame.addEventListener("urlchange", (e) => { if (!e.url) return; this.url = e.url; }); const handleSubmit = () => { this.url = this.url.trim(); // frame.go(this.url) if (!this.url.startsWith("http")) { this.url = "https://" + this.url; } return frame.go(this.url); }; const cfg = h(Config); document.body.appendChild(cfg); this.githubURL = `https://github.com/MercuryWorkshop/scramjet/commit/${$scramjetVersion.build}`; return html`
{ this.url = e.target.value; }} on:keyup=${(e) => e.keyCode == 13 && (store.url = this.url) && handleSubmit()}>

scramjet ${$scramjetVersion.version} ${$scramjetVersion.build}

${frame.frame}
`; } window.addEventListener("load", async () => { const root = document.getElementById("app"); try { root.replaceWith(h(BrowserApp)); } catch (e) { root.replaceWith(document.createTextNode("" + e)); throw e; } function b64(buffer) { let binary = ""; const bytes = new Uint8Array(buffer); const len = bytes.byteLength; for (let i = 0; i < len; i++) { binary += String.fromCharCode(bytes[i]); } return btoa(binary); } const arraybuffer = await (await fetch("/assets/scramjet.png")).arrayBuffer(); console.log( "%cb", ` background-image: url(data:image/png;base64,${b64(arraybuffer)}); color: transparent; padding-left: 200px; padding-bottom: 100px; background-size: contain; background-position: center center; background-repeat: no-repeat; ` ); });