mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-17 05:20:01 -04:00
Move some things around to be more consistent
This commit is contained in:
parent
da7edfe3e4
commit
20feb65b80
3 changed files with 3 additions and 4 deletions
54
src/pages/ProxyFrame.tsx
Normal file
54
src/pages/ProxyFrame.tsx
Normal file
|
@ -0,0 +1,54 @@
|
|||
import { RammerheadEncode } from "../util/RammerheadEncode";
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__uv$config: any;
|
||||
__dynamic$config: any;
|
||||
}
|
||||
}
|
||||
|
||||
export function ProxyFrame(props: { url: string }) {
|
||||
// pass the URL encoded with encodeURIcomponent
|
||||
var localProxy = localStorage.getItem("proxy") || "automatic";
|
||||
var [ProxiedUrl, setProxiedUrl] = useState<string | undefined>(undefined);
|
||||
|
||||
var decodedUrl = decodeURIComponent(props.url);
|
||||
|
||||
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://")) {
|
||||
decodedUrl = "https://" + decodedUrl;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// For now we can redirect to the results. In the future we will add an if statement looking for the users proxy display choice
|
||||
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);
|
||||
} else if (localProxy === "dynamic") {
|
||||
window.location.href =
|
||||
window.__dynamic$config.prefix + encodeURIComponent(decodedUrl);
|
||||
} else {
|
||||
// use UV for automatic
|
||||
window.location.href =
|
||||
window.__uv$config.prefix + window.__uv$config.encodeUrl(decodedUrl);
|
||||
}
|
||||
}, [localProxy]);
|
||||
|
||||
console.log(ProxiedUrl);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-black">{props.url}</h1>
|
||||
<h1 className="text-black">{localProxy}</h1>
|
||||
<h1 className="text-black">{ProxiedUrl}</h1>
|
||||
</div>
|
||||
); // @TODO: Routing (iframe, ab, direct, etc.)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue