Merge pull request #69 from RadiusProxy/aboutBlank
Add About blank cloaking (incomplete do not merge)
This commit is contained in:
commit
e21c051293
8 changed files with 117 additions and 6 deletions
2
.github/workflows/releases.yml
vendored
2
.github/workflows/releases.yml
vendored
|
|
@ -36,7 +36,7 @@ jobs:
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --no-frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: Create Release Pull Request or Publish
|
- name: Create Release Pull Request or Publish
|
||||||
id: changesets
|
id: changesets
|
||||||
|
|
|
||||||
|
|
@ -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)'}`>
|
<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
|
<Icon name="lucide:link" class="h-5 w-5" /> Social Links
|
||||||
</a>
|
</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>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
63
src/pages/settings/cloaking.astro
Normal file
63
src/pages/settings/cloaking.astro
Normal 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>
|
||||||
|
|
@ -37,7 +37,7 @@ class SW {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#search(input: string, template: string) {
|
search(input: string, template: string) {
|
||||||
try {
|
try {
|
||||||
return new URL(input).toString();
|
return new URL(input).toString();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
@ -52,7 +52,7 @@ class SW {
|
||||||
|
|
||||||
encodeURL(string: string): string {
|
encodeURL(string: string): string {
|
||||||
const proxy = this.#storageManager.getVal("proxy") as "uv" | "sj";
|
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"
|
return proxy === "uv"
|
||||||
? `${__uv$config.prefix}${__uv$config.encodeUrl!(input)}`
|
? `${__uv$config.prefix}${__uv$config.encodeUrl!(input)}`
|
||||||
: this.#scramjetController!.encodeUrl(input);
|
: this.#scramjetController!.encodeUrl(input);
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,48 @@ class Settings {
|
||||||
this.#storageManager.setVal("searchEngine", engine || SearchEngines.DuckDuckGo);
|
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() {
|
async *#init() {
|
||||||
yield this.theme(this.#storageManager.getVal("theme") || "default");
|
yield this.theme(this.#storageManager.getVal("theme") || "default");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Props } from "astro";
|
import type { Props } from "astro";
|
||||||
|
|
||||||
interface SettingsProps extends Props {
|
interface SettingsProps extends Props {
|
||||||
active: "appearance" | "credits" | "links" | "proxy";
|
active: "appearance" | "credits" | "links" | "proxy" | "cloaking";
|
||||||
title: string;
|
title: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue