mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
annoying ass logging
This commit is contained in:
parent
58f6a4330a
commit
d7c6044602
2 changed files with 53 additions and 46 deletions
|
@ -25,13 +25,13 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
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) {
|
||||
dbg.debug("setting cookie", value);
|
||||
// dbg.debug("setting cookie", value);
|
||||
const cookie = parse(value)[0];
|
||||
|
||||
let date = new Date();
|
||||
let expires = cookie.expires;
|
||||
|
||||
dbg.error("expires", expires);
|
||||
// dbg.error("expires", expires);
|
||||
// if (expires instanceof Date) {
|
||||
// if (isNaN(expires.getTime())) return;
|
||||
// if (expires.getTime() < date.getTime()) return;
|
||||
|
|
|
@ -8,49 +8,56 @@ export default function (client: ScramjetClient, self: Self) {
|
|||
},
|
||||
});
|
||||
|
||||
// client.Proxy("navigator.serviceWorker.register", {
|
||||
// apply(ctx) {
|
||||
// if (ctx.args[0] instanceof URL) ctx.args[0] = ctx.args[0].href;
|
||||
// let url = encodeUrl(ctx.args[0]) + "?dest=serviceworker";
|
||||
// if (ctx.args[1] && ctx.args[1].type === "module") {
|
||||
// url += "&type=module";
|
||||
// }
|
||||
// let worker = new SharedWorker(url);
|
||||
//
|
||||
// let handle = worker.port;
|
||||
//
|
||||
// navigator.serviceWorker.controller.postMessage({
|
||||
// scramjet$type: "registerServiceWorker",
|
||||
// port: handle,
|
||||
// });
|
||||
//
|
||||
// const fakeRegistration = new Proxy(
|
||||
// {
|
||||
// __proto__: ServiceWorkerRegistration.prototype,
|
||||
// },
|
||||
// {
|
||||
// get(target, prop) {
|
||||
// if (prop === "installing") {
|
||||
// return null;
|
||||
// }
|
||||
// if (prop === "waiting") {
|
||||
// return null;
|
||||
// }
|
||||
// if (prop === "active") {
|
||||
// return handle;
|
||||
// }
|
||||
// if (prop === "scope") {
|
||||
// return ctx.args[0];
|
||||
// }
|
||||
//
|
||||
// return Reflect.get(target, prop);
|
||||
// },
|
||||
// }
|
||||
// );
|
||||
//
|
||||
// ctx.return(new Promise((resolve) => resolve(fakeRegistration)));
|
||||
// },
|
||||
// });
|
||||
client.Proxy("navigator.serviceWorker.register", {
|
||||
apply(ctx) {
|
||||
if (ctx.args[0] instanceof URL) ctx.args[0] = ctx.args[0].href;
|
||||
let url = encodeUrl(ctx.args[0]) + "?dest=serviceworker";
|
||||
if (ctx.args[1] && ctx.args[1].type === "module") {
|
||||
url += "&type=module";
|
||||
}
|
||||
let worker = new SharedWorker(url);
|
||||
|
||||
delete self.navigator.serviceWorker;
|
||||
let handle = worker.port;
|
||||
|
||||
navigator.serviceWorker.controller.postMessage(
|
||||
{
|
||||
scramjet$type: "registerServiceWorker",
|
||||
port: handle,
|
||||
},
|
||||
[handle]
|
||||
);
|
||||
|
||||
const fakeRegistration = new Proxy(
|
||||
{
|
||||
__proto__: ServiceWorkerRegistration.prototype,
|
||||
},
|
||||
{
|
||||
get(target, prop) {
|
||||
if (prop === "installing") {
|
||||
return null;
|
||||
}
|
||||
if (prop === "waiting") {
|
||||
return null;
|
||||
}
|
||||
if (prop === "active") {
|
||||
return handle;
|
||||
}
|
||||
if (prop === "scope") {
|
||||
return ctx.args[0];
|
||||
}
|
||||
|
||||
if (prop === "addEventListener") {
|
||||
return () => {};
|
||||
}
|
||||
|
||||
return Reflect.get(target, prop);
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
ctx.return(new Promise((resolve) => resolve(fakeRegistration)));
|
||||
},
|
||||
});
|
||||
|
||||
// delete self.navigator.serviceWorker;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue