mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-15 07:20:02 -04:00
shitty document.cookie impl
This commit is contained in:
parent
4829cd4a23
commit
956c0aa02a
1 changed files with 13 additions and 22 deletions
|
@ -1,28 +1,22 @@
|
||||||
import { parse } from "set-cookie-parser";
|
import { parse } from "set-cookie-parser";
|
||||||
import { ScramjetClient } from "../client";
|
import { ScramjetClient } from "../client";
|
||||||
|
import IDBMapSync from "@webreflection/idb-map/sync";
|
||||||
|
|
||||||
export default function (client: ScramjetClient, self: typeof window) {
|
export default function (client: ScramjetClient, self: typeof window) {
|
||||||
|
let cookieStore = new IDBMapSync(client.url.host, {
|
||||||
|
durability: "relaxed",
|
||||||
|
prefix: "Cookies",
|
||||||
|
});
|
||||||
|
|
||||||
client.Trap("Document.prototype.cookie", {
|
client.Trap("Document.prototype.cookie", {
|
||||||
get(ctx) {
|
get(ctx) {
|
||||||
const cookiestring = ctx.get();
|
let cookies = cookieStore.entries();
|
||||||
// dbg.log("original cookiestring", cookiestring);
|
if (client.url.protocol !== "https:") {
|
||||||
//
|
cookies = cookies.filter(([_k, v]) => !v.args.includes(["Secure"]));
|
||||||
// if (!cookiestring) return "";
|
}
|
||||||
//
|
cookies = cookies.filter(([_k, v]) => !v.args.includes(["HttpOnly"]));
|
||||||
//
|
cookies = Array.from(cookies.map(([k, v]) => `${k}=${v.value}`));
|
||||||
// let string = "";
|
return cookies.join("; ");
|
||||||
//
|
|
||||||
// for (const cookiestr of cookiestring.split(";")) {
|
|
||||||
// const cookie = parse(cookiestr.trim())[0];
|
|
||||||
// if (cookie.name.startsWith(client.url.hostname + "@")) {
|
|
||||||
// let name = cookie.name.substring(client.url.hostname.length + 1);
|
|
||||||
// string += `${name}=${cookie.value}; `;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return string.trimEnd();
|
|
||||||
|
|
||||||
return "sp_t=00246e00653d39d1341bbe9d10f138c4; OptanonConsent=isGpcEnabled=0&datestamp=Sat+Jul+20+2024+16%3A11%3A26+GMT-0400+(Eastern+Daylight+Time)&version=202405.2.0&browserGpcFlag=0&isIABGlobal=false&hosts=&landingPath=https%3A%2F%2Fopen.spotify.com%2F&groups=BG169%3A1%2Ct00%3A1%2Ci00%3A1%2CBG170%3A1%2Cs00%3A1%2Cf00%3A1%2Cm00%3A1%2Cf11%3A1";
|
|
||||||
},
|
},
|
||||||
set(ctx, value: string) {
|
set(ctx, value: string) {
|
||||||
// dbg.debug("setting cookie", value);
|
// dbg.debug("setting cookie", value);
|
||||||
|
@ -43,7 +37,4 @@ export default function (client: ScramjetClient, self: typeof window) {
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
delete self.cookieStore;
|
delete self.cookieStore;
|
||||||
|
|
||||||
// sp_t=00e49dc8-59d0-4b5f-9beb-ec7b67368498; path=/; expires=Invalid Date
|
|
||||||
// OTZ=7653361_72_76_104100_72_446760;path=/;expires=Mon, 19 Aug 2024 20:01:06 GMT;secure
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue