header flattening

This commit is contained in:
velzie 2024-07-14 19:10:13 -04:00
parent a94cf9dd6a
commit d0df4a8357
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
2 changed files with 18 additions and 11 deletions

View file

@ -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) { if (response.body) {
switch (request.destination) { switch (request.destination) {
case "iframe": case "iframe":
case "document": case "document":
if (responseHeaders["content-type"].toString().startsWith("text/html")) { if (responseHeaders["content-type"]?.toString()?.startsWith("text/html")) {
responseBody = rewriteHtml(await response.text(), url); responseBody = rewriteHtml(await response.text(), url);
} else { } else {
responseBody = response.body; responseBody = response.body;

View file

@ -1,18 +1,20 @@
navigator.serviceWorker.register("./sw.js", { 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 connection = new BareMux.BareMuxConnection("/baremux/worker.js")
const flex = css`display: flex;`; const flex = css`display: flex;`;
const col = css`flex-direction: column;`; const col = css`flex-direction: column;`;
const store = $store({ const store = $store({
url: "https://google.com", url: "https://google.com",
wispurl: "wss://wisp.mercurywork.shop/", wispurl: "wss://wisp.mercurywork.shop/",
bareurl: (location.protocol === "https:" ? "https" : "http") + "://" + location.host + "/bare/", bareurl: (location.protocol === "https:" ? "https" : "http") + "://" + location.host + "/bare/",
}, { ident: "settings", backing: "localstorage", autosave: "auto" }); }, { ident: "settings", backing: "localstorage", autosave: "auto" });
connection.setTransport("/baremod/index.mjs", [store.bareurl]) connection.setTransport("/baremod/index.mjs", [store.bareurl])
function App() { function App() {
this.urlencoded = ""; this.urlencoded = "";
this.css = ` this.css = `
width: 100%; width: 100%;
height: 100%; height: 100%;
color: #e0def4; color: #e0def4;
@ -70,8 +72,8 @@ function App() {
padding: 0.45em; padding: 0.45em;
} }
`; `;
return html` return html`
<div> <div>
<h1>Percury Unblocker</h1> <h1>Percury Unblocker</h1>
<p>surf the unblocked and mostly buggy web</p> <p>surf the unblocked and mostly buggy web</p>
@ -95,5 +97,5 @@ function App() {
} }
window.addEventListener("load", () => { window.addEventListener("load", () => {
document.body.appendChild(h(App)) document.body.appendChild(h(App))
}) })