This commit is contained in:
Percs 2024-07-19 16:15:05 -05:00
parent 3ced0defc4
commit 9305bf7ce3
3 changed files with 21 additions and 13 deletions

View file

@ -151,7 +151,6 @@ for (const target of [Node.prototype, document]) {
},
});
}
} catch (e) { }
} catch (e) {}
}
}

View file

@ -8,7 +8,7 @@ const store = new IDBMapSync(locationProxy.host, {
await store.sync();
const localStorageProxy = new Proxy(window.localStorage, {
const localStorageProxy = new Proxy(window.localStorage, {
get(target, prop) {
switch (prop) {
case "getItem":
@ -68,17 +68,17 @@ const sessionStorageProxy = new Proxy(window.sessionStorage, {
case "getItem":
return (key: string) => {
return target.getItem(locationProxy.host + "@" + key);
}
};
case "setItem":
return (key: string, value: string) => {
target.setItem(locationProxy.host + "@" + key, value);
}
};
case "removeItem":
return (key: string) => {
target.removeItem(locationProxy.host + "@" + key);
}
};
case "clear":
return () => {
@ -87,14 +87,16 @@ const sessionStorageProxy = new Proxy(window.sessionStorage, {
target.removeItem(key);
}
}
}
};
case "key":
return (index: number) => {
const keys = Object.keys(target).filter((key) => key.startsWith(locationProxy.host));
const keys = Object.keys(target).filter((key) =>
key.startsWith(locationProxy.host)
);
return target.getItem(keys[index]);
}
};
case "length":
return target.length;
@ -109,8 +111,11 @@ const sessionStorageProxy = new Proxy(window.sessionStorage, {
},
defineProperty(target, property, attributes) {
target.setItem(locationProxy.host + "@" + (property as string), attributes.value);
target.setItem(
locationProxy.host + "@" + (property as string),
attributes.value
);
return true;
},
});
@ -119,4 +124,4 @@ delete window.localStorage;
delete window.sessionStorage;
window.localStorage = localStorageProxy;
window.sessionStorage = sessionStorageProxy;
window.sessionStorage = sessionStorageProxy;

View file

@ -28,7 +28,11 @@ const col = css`
const store = $store(
{
url: "https://google.com",
wispurl: (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/",
wispurl:
(location.protocol === "https:" ? "wss" : "ws") +
"://" +
location.host +
"/wisp/",
bareurl:
(location.protocol === "https:" ? "https" : "http") +
"://" +