From d0df4a8357c631a5125eb874e562ac798412d0e5 Mon Sep 17 00:00:00 2001 From: velzie Date: Sun, 14 Jul 2024 19:10:13 -0400 Subject: [PATCH] header flattening --- src/worker/index.ts | 7 ++++++- static/ui.js | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/worker/index.ts b/src/worker/index.ts index 7d30c9e..3d67269 100644 --- a/src/worker/index.ts +++ b/src/worker/index.ts @@ -70,11 +70,16 @@ self.ScramjetServiceWorker = class ScramjetServiceWorker { } } + for (let header in responseHeaders) { + // flatten everything past here + if (responseHeaders[header] instanceof Array) responseHeaders[header] = responseHeaders[header][0]; + } + if (response.body) { switch (request.destination) { case "iframe": case "document": - if (responseHeaders["content-type"].toString().startsWith("text/html")) { + if (responseHeaders["content-type"]?.toString()?.startsWith("text/html")) { responseBody = rewriteHtml(await response.text(), url); } else { responseBody = response.body; diff --git a/static/ui.js b/static/ui.js index 1d4edd4..2eab798 100644 --- a/static/ui.js +++ b/static/ui.js @@ -1,18 +1,20 @@ navigator.serviceWorker.register("./sw.js", { - scope: $scramjet.config.prefix -}) + scope: $scramjet.config.prefix +}).then((reg) => { + reg.update(); +}); const connection = new BareMux.BareMuxConnection("/baremux/worker.js") const flex = css`display: flex;`; const col = css`flex-direction: column;`; const store = $store({ - url: "https://google.com", - wispurl: "wss://wisp.mercurywork.shop/", - bareurl: (location.protocol === "https:" ? "https" : "http") + "://" + location.host + "/bare/", + url: "https://google.com", + wispurl: "wss://wisp.mercurywork.shop/", + bareurl: (location.protocol === "https:" ? "https" : "http") + "://" + location.host + "/bare/", }, { ident: "settings", backing: "localstorage", autosave: "auto" }); connection.setTransport("/baremod/index.mjs", [store.bareurl]) function App() { - this.urlencoded = ""; - this.css = ` + this.urlencoded = ""; + this.css = ` width: 100%; height: 100%; color: #e0def4; @@ -70,8 +72,8 @@ function App() { padding: 0.45em; } `; - - return html` + + return html`

Percury Unblocker

surf the unblocked and mostly buggy web

@@ -95,5 +97,5 @@ function App() { } window.addEventListener("load", () => { - document.body.appendChild(h(App)) + document.body.appendChild(h(App)) })