Add blob cloaking
This commit is contained in:
parent
d3f6c0ab06
commit
b0ddd8eb08
3 changed files with 59 additions and 11 deletions
|
|
@ -127,6 +127,9 @@ const link = Astro.url.searchParams.get("redir");
|
||||||
|
|
||||||
customElements.define('link-element', CustomComponent);
|
customElements.define('link-element', CustomComponent);
|
||||||
document.addEventListener("astro:page-load", async () => {
|
document.addEventListener("astro:page-load", async () => {
|
||||||
|
try {
|
||||||
await init();
|
await init();
|
||||||
|
}
|
||||||
|
catch (_) {}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,16 @@ import Button from "@components/ui/Button.astro";
|
||||||
const button = document.getElementById("aboutBlankLaunch") as HTMLButtonElement;
|
const button = document.getElementById("aboutBlankLaunch") as HTMLButtonElement;
|
||||||
button.addEventListener("click", () => {
|
button.addEventListener("click", () => {
|
||||||
const url = sw.search(input.value, storage.getVal('searchEngine'));
|
const url = sw.search(input.value, storage.getVal('searchEngine'));
|
||||||
settings.aboutBlank(url);
|
settings.cloak(url).aboutBlank();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBlob = async (settings: Settings, sw: SW, storage: StoreManager<"radius||settings">) => {
|
||||||
|
const input = document.getElementById("blobCloaker") as HTMLInputElement;
|
||||||
|
const button = document.getElementById("blobLaunch") as HTMLButtonElement;
|
||||||
|
button.addEventListener("click", () => {
|
||||||
|
const url = sw.search(input.value, storage.getVal('searchEngine'));
|
||||||
|
settings.cloak(url).blob();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -45,6 +54,10 @@ import Button from "@components/ui/Button.astro";
|
||||||
const settings = await Settings.getInstance();
|
const settings = await Settings.getInstance();
|
||||||
const sw = SW.getInstance().next().value!;
|
const sw = SW.getInstance().next().value!;
|
||||||
const storageManager = new StoreManager<"radius||settings">("radius||settings");
|
const storageManager = new StoreManager<"radius||settings">("radius||settings");
|
||||||
|
try {
|
||||||
await handleAb(settings, sw, storageManager);
|
await handleAb(settings, sw, storageManager);
|
||||||
|
await handleBlob(settings, sw, storageManager);
|
||||||
|
}
|
||||||
|
catch (_) {}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -80,14 +80,46 @@ class Settings {
|
||||||
this.#storageManager.setVal("searchEngine", engine || SearchEngines.DuckDuckGo);
|
this.#storageManager.setVal("searchEngine", engine || SearchEngines.DuckDuckGo);
|
||||||
}
|
}
|
||||||
|
|
||||||
aboutBlank(location: string) {
|
cloak(location: string) {
|
||||||
window.location.replace(location);
|
return {
|
||||||
|
aboutBlank: () => {
|
||||||
const win = window.open();
|
const win = window.open();
|
||||||
const iframe = win!.document.createElement("iframe") as HTMLIFrameElement;
|
if (!win) return;
|
||||||
win!.document.body.setAttribute('style', 'margin: 0; height: 100vh; width: 100%;');
|
window.location.replace(location);
|
||||||
|
const iframe = win.document.createElement("iframe") as HTMLIFrameElement;
|
||||||
|
win.document.body.setAttribute('style', 'margin: 0; height: 100vh; width: 100%;');
|
||||||
iframe.setAttribute('style', 'border: none; width: 100%; height: 100%; margin: 0;');
|
iframe.setAttribute('style', 'border: none; width: 100%; height: 100%; margin: 0;');
|
||||||
iframe.src = window.location.href;
|
iframe.src = window.location.href;
|
||||||
win!.document.body.appendChild(iframe);
|
win.document.body.appendChild(iframe);
|
||||||
|
},
|
||||||
|
blob: () => {
|
||||||
|
const win = window.open();
|
||||||
|
if (!win) return;
|
||||||
|
window.location.replace(location);
|
||||||
|
const content = `
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style type="text/css">
|
||||||
|
body, html {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<iframe style="border: none; width: 100%; height: 100%;" src="${window.location.href}"></iframe>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
const blob = new Blob([content], { type: 'text/html' });
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
win.location.href = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async *#init() {
|
async *#init() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue