proxyframe dev (WIP)

This commit is contained in:
rift 2023-12-22 16:55:43 -06:00
parent 5f27a4bc92
commit f11c377294
2 changed files with 45 additions and 14 deletions

View file

@ -11,14 +11,18 @@ declare global {
export function ProxyFrame(props: { url: string }) {
// pass the URL encoded with encodeURIcomponent
var localProxy = localStorage.getItem("proxy") || "automatic";
var proxyMode = localStorage.getItem("proxyMode") || "direct";
var [ProxiedUrl, setProxiedUrl] = useState<string | undefined>(undefined);
var decodedUrl = decodeURIComponent(props.url);
var proxyRef;
if (!decodedUrl.includes(".")) {
decodedUrl = "https://www.google.com/search?q=" + decodedUrl; // If the users input has no . then we change it to a google query. TODO: Feature to change search engines
}
if (decodedUrl.startsWith("http://") || !decodedUrl.startsWith("https://")) {
if (!decodedUrl.startsWith("http://") || !decodedUrl.startsWith("https://")) {
decodedUrl = "https://" + decodedUrl;
}
@ -27,28 +31,55 @@ export function ProxyFrame(props: { url: string }) {
if (localProxy === "rammerhead") {
RammerheadEncode(decodedUrl).then((result: string) => {
setProxiedUrl(result);
window.location.href = result;
});
} else if (localProxy === "ultraviolet") {
window.location.href =
window.__uv$config.prefix + window.__uv$config.encodeUrl(decodedUrl);
setProxiedUrl(
window.__uv$config.prefix + window.__uv$config.encodeUrl(decodedUrl)
);
} else if (localProxy === "dynamic") {
window.location.href =
window.__dynamic$config.prefix + encodeURIComponent(decodedUrl);
setProxiedUrl(
window.__dynamic$config.prefix + encodeURIComponent(decodedUrl)
);
} else {
// use UV for automatic
window.location.href =
window.__uv$config.prefix + window.__uv$config.encodeUrl(decodedUrl);
setProxiedUrl(
window.__uv$config.prefix + window.__uv$config.encodeUrl(decodedUrl)
);
}
}, [localProxy]);
console.log(ProxiedUrl);
if (proxyMode == "direct") {
window.location.href = ProxiedUrl;
} else if (proxyMode == "aboutblank") {
const newWindow = window.open("about:blank", "_blank");
const newDocument = newWindow.document.open();
newDocument.write(`
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body, html
{
margin: 0; padding: 0; height: 100%; overflow: hidden;
}
</style>
</head>
<body>
<iframe style="border: none; width: 100%; height: 100vh;" src="${
window.location.origin + ProxiedUrl
}"></iframe>
</body>
</html>
`);
newDocument.close()
window.location.replace("/");
} else {
// iframe
}
return (
<div>
<h1 className="text-black">{props.url}</h1>
<h1 className="text-black">{localProxy}</h1>
<h1 className="text-black">{ProxiedUrl}</h1>
<div class="h-screen w-screen bg-primary">
{proxyMode === "direct" && <h1>Loading {localProxy}...</h1>}
</div>
); // @TODO: Routing (iframe, ab, direct, etc.)
}

View file

@ -17,7 +17,7 @@ export function DiscordPage() {
{t("discord.button1")}
</button>
</a>
<a href="/" class="p-6">
<a href="${window.location.href = '/go/' + encodeURIComponent(https://discord.gg/unblocker)}" class="p-6">
<button class="font-roboto h-14 w-56 rounded-2xl border border-input-border-color bg-input p-2 text-center text-xl placeholder:text-input-text focus:outline-none">
{t("discord.button2")}
</button>