mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-16 21:10:02 -04:00
proxyframe dev (WIP)
This commit is contained in:
parent
5f27a4bc92
commit
f11c377294
2 changed files with 45 additions and 14 deletions
|
@ -11,14 +11,18 @@ declare global {
|
||||||
export function ProxyFrame(props: { url: string }) {
|
export function ProxyFrame(props: { url: string }) {
|
||||||
// pass the URL encoded with encodeURIcomponent
|
// pass the URL encoded with encodeURIcomponent
|
||||||
var localProxy = localStorage.getItem("proxy") || "automatic";
|
var localProxy = localStorage.getItem("proxy") || "automatic";
|
||||||
|
var proxyMode = localStorage.getItem("proxyMode") || "direct";
|
||||||
|
|
||||||
var [ProxiedUrl, setProxiedUrl] = useState<string | undefined>(undefined);
|
var [ProxiedUrl, setProxiedUrl] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
var decodedUrl = decodeURIComponent(props.url);
|
var decodedUrl = decodeURIComponent(props.url);
|
||||||
|
|
||||||
|
var proxyRef;
|
||||||
|
|
||||||
if (!decodedUrl.includes(".")) {
|
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
|
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;
|
decodedUrl = "https://" + decodedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,28 +31,55 @@ export function ProxyFrame(props: { url: string }) {
|
||||||
if (localProxy === "rammerhead") {
|
if (localProxy === "rammerhead") {
|
||||||
RammerheadEncode(decodedUrl).then((result: string) => {
|
RammerheadEncode(decodedUrl).then((result: string) => {
|
||||||
setProxiedUrl(result);
|
setProxiedUrl(result);
|
||||||
window.location.href = result;
|
|
||||||
});
|
});
|
||||||
} else if (localProxy === "ultraviolet") {
|
} else if (localProxy === "ultraviolet") {
|
||||||
window.location.href =
|
setProxiedUrl(
|
||||||
window.__uv$config.prefix + window.__uv$config.encodeUrl(decodedUrl);
|
window.__uv$config.prefix + window.__uv$config.encodeUrl(decodedUrl)
|
||||||
|
);
|
||||||
} else if (localProxy === "dynamic") {
|
} else if (localProxy === "dynamic") {
|
||||||
window.location.href =
|
setProxiedUrl(
|
||||||
window.__dynamic$config.prefix + encodeURIComponent(decodedUrl);
|
window.__dynamic$config.prefix + encodeURIComponent(decodedUrl)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// use UV for automatic
|
// use UV for automatic
|
||||||
window.location.href =
|
setProxiedUrl(
|
||||||
window.__uv$config.prefix + window.__uv$config.encodeUrl(decodedUrl);
|
window.__uv$config.prefix + window.__uv$config.encodeUrl(decodedUrl)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [localProxy]);
|
}, [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 (
|
return (
|
||||||
<div>
|
<div class="h-screen w-screen bg-primary">
|
||||||
<h1 className="text-black">{props.url}</h1>
|
{proxyMode === "direct" && <h1>Loading {localProxy}...</h1>}
|
||||||
<h1 className="text-black">{localProxy}</h1>
|
|
||||||
<h1 className="text-black">{ProxiedUrl}</h1>
|
|
||||||
</div>
|
</div>
|
||||||
); // @TODO: Routing (iframe, ab, direct, etc.)
|
); // @TODO: Routing (iframe, ab, direct, etc.)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ export function DiscordPage() {
|
||||||
{t("discord.button1")}
|
{t("discord.button1")}
|
||||||
</button>
|
</button>
|
||||||
</a>
|
</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">
|
<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")}
|
{t("discord.button2")}
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue