Merge pull request #69 from RadiusProxy/aboutBlank

Add About blank cloaking (incomplete do not merge)
This commit is contained in:
MotorTruck1221 2025-06-08 21:48:10 -06:00 committed by GitHub
commit e21c051293
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 117 additions and 6 deletions

View file

@ -36,7 +36,7 @@ jobs:
cache: "pnpm"
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
run: pnpm install --frozen-lockfile
- name: Create Release Pull Request or Publish
id: changesets

View file

@ -17,4 +17,7 @@ const { active } = Astro.props;
<a href="/settings/links/" class=`gap-2 px-4 py-2 rounded-lg h-10 w-full text-sm font-medium transition-colors items-center justify-start inline-flex ${active === "links" ? 'bg-(--secondary) hover:bg-(--secondary)/[0.8]' : 'bg-(--background) hover:bg-(--accent)'}`>
<Icon name="lucide:link" class="h-5 w-5" /> Social Links
</a>
<a href="/settings/cloaking/" class=`gap-2 px-4 py-2 rounded-lg h-10 w-full text-sm font-medium transition-colors items-center justify-start inline-flex ${active === "cloaking" ? 'bg-(--secondary) hover:bg-(--secondary)/[0.8]' : 'bg-(--background) hover:bg-(--accent)'}`>
<Icon name="lucide:eye-off" class="h-5 w-5" /> Cloaking
</a>
</div>

View file

@ -127,6 +127,9 @@ const link = Astro.url.searchParams.get("redir");
customElements.define('link-element', CustomComponent);
document.addEventListener("astro:page-load", async () => {
try {
await init();
}
catch (_) {}
});
</script>

View file

@ -0,0 +1,63 @@
---
import SettingsLayout from "@layouts/SettingsLayout.astro";
import Input from "@components/ui/Input.astro";
import Button from "@components/ui/Button.astro";
---
<SettingsLayout active="cloaking" title="Cloaking">
<div class="w-full flex-grow">
<div class="w-full flex flex-row gap-4">
<div class="w-1/2">
<div>
<p> About Blank </p>
<Input id="aboutBlankCloaker" placeholder="Redirect url (EX: https://google.com)" />
</div>
<div class="mt-2">
<Button id="aboutBlankLaunch" text="Cloak!" icon="lucide:square-arrow-out-up-right" />
</div>
</div>
<div class="w-1/2">
<div>
<p> Blob </p>
<Input id="blobCloaker" placeholder="Redirect url (EX: https://google.com)" />
</div>
<div class="mt-2">
<Button id="blobLaunch" text="Cloak!" icon="lucide:square-arrow-out-up-right" />
</div>
</div>
</div>
</div>
</SettingsLayout>
<script>
import { Settings } from "@utils/settings.ts";
import { StoreManager } from "@utils/storage";
import { SW } from "@utils/proxy.ts";
const handleAb = async (settings: Settings, sw: SW, storage: StoreManager<"radius||settings">) => {
const input = document.getElementById("aboutBlankCloaker") as HTMLInputElement;
const button = document.getElementById("aboutBlankLaunch") as HTMLButtonElement;
button.addEventListener("click", () => {
const url = sw.search(input.value, storage.getVal('searchEngine'));
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();
});
};
document.addEventListener('astro:page-load', async () => {
const settings = await Settings.getInstance();
const sw = SW.getInstance().next().value!;
const storageManager = new StoreManager<"radius||settings">("radius||settings");
try {
await handleAb(settings, sw, storageManager);
await handleBlob(settings, sw, storageManager);
}
catch (_) {}
});
</script>

View file

@ -37,7 +37,7 @@ class SW {
}
}
#search(input: string, template: string) {
search(input: string, template: string) {
try {
return new URL(input).toString();
} catch (_) {}
@ -52,7 +52,7 @@ class SW {
encodeURL(string: string): string {
const proxy = this.#storageManager.getVal("proxy") as "uv" | "sj";
const input = this.#search(string, this.#storageManager.getVal("searchEngine"));
const input = this.search(string, this.#storageManager.getVal("searchEngine"));
return proxy === "uv"
? `${__uv$config.prefix}${__uv$config.encodeUrl!(input)}`
: this.#scramjetController!.encodeUrl(input);

View file

@ -80,6 +80,48 @@ class Settings {
this.#storageManager.setVal("searchEngine", engine || SearchEngines.DuckDuckGo);
}
cloak(location: string) {
return {
aboutBlank: () => {
const win = window.open();
if (!win) return;
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.src = window.location.href;
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() {
yield this.theme(this.#storageManager.getVal("theme") || "default");
}

View file

@ -1,7 +1,7 @@
import type { Props } from "astro";
interface SettingsProps extends Props {
active: "appearance" | "credits" | "links" | "proxy";
active: "appearance" | "credits" | "links" | "proxy" | "cloaking";
title: string;
}