cookie DEI program

This commit is contained in:
velzie 2025-03-06 20:29:36 -05:00
parent ae843301de
commit ff719ee6fc
No known key found for this signature in database
GPG key ID: 456761F526D20BB0
3 changed files with 41 additions and 9 deletions

View file

@ -1,13 +1,22 @@
import type { MessageC2W, MessageW2C } from "../../worker";
import { ScramjetClient } from "../client";
export default function (client: ScramjetClient, self: typeof window) {
client.serviceWorker.addEventListener("message", ({ data }) => {
if (!("scramjet$type" in data)) return;
client.serviceWorker.addEventListener(
"message",
({ data }: { data: MessageW2C }) => {
if (!("scramjet$type" in data)) return;
if (data.scramjet$type === "cookie") {
client.cookieStore.setCookies([data.cookie], new URL(data.url));
if (data.scramjet$type === "cookie") {
client.cookieStore.setCookies([data.cookie], new URL(data.url));
let msg = {
scramjet$token: data.scramjet$token,
scramjet$type: "cookie",
};
client.serviceWorker.controller.postMessage(msg);
}
}
});
);
client.Trap("Document.prototype.cookie", {
get() {