"use client"; import Sidebar from "@/components/sidebar"; import { Button } from "@/components/ui/button"; import { encodeXor } from "@/lib/utils"; import { useEffect, useRef, useState } from "react"; import store from "store2"; import * as Lucide from "lucide-react"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; interface ContentWindow extends Window { __uv$location: Location; } declare global { interface Window { chemical: any; } } export default function Route({ params }: { params: { route: string[] } }) { const ref = useRef(null); const [open, setOpen] = useState(false); const route = params.route.join("/"); const [tabIcon, setTabIcon] = useState(""); const [tabName, setTabName] = useState(""); const [shortcutted, setShortcutted] = useState(false); useEffect(() => { async function go() { if (ref.current) { ref.current.src = await window.chemical.encode( atob(decodeURIComponent(route)), { autoHttps: true, searchEngine: "https://www.google.com/search?q=%s", } ); } } go(); }, []); function triggerShortcut() { store.set("shortcuts", [], false); if (!ref.current || !ref.current.contentWindow) return; const contentWindow = ref.current.contentWindow as ContentWindow; if (!("__uv$location" in contentWindow)) return; const shortcuts: any[] = store("shortcuts"); if ( shortcuts.some((value) => value.url == contentWindow.__uv$location.href) ) { store( "shortcuts", shortcuts.filter( (value) => value.url !== contentWindow.__uv$location.href ) ); setShortcutted(false); } else { store("shortcuts", [ ...store("shortcuts"), { image: ( contentWindow.document.querySelector( "link[rel*='icon']" ) as HTMLLinkElement )?.href || `${contentWindow.__uv$location.origin}/favicon.ico`, title: contentWindow.document.title, url: contentWindow.__uv$location.href, }, ]); setShortcutted(true); } } function handleLoad() { if (!ref.current || !ref.current.contentWindow) return; const contentWindow = ref.current.contentWindow as ContentWindow; setTabName(contentWindow.document.title); setTabIcon( ( contentWindow.document.querySelector( "link[rel*='icon']" ) as HTMLLinkElement )?.href || `${contentWindow.__uv$location.origin}/favicon.ico` ); store.set("shortcuts", [], false); const shortcuts: any[] = store("shortcuts"); if ( shortcuts.some((value) => value.url == contentWindow.__uv$location.href) ) { setShortcutted(true); } } return (
{tabIcon ? ( ) : ( )}

{tabName ? tabName : "Radius"}

Back Reload Shortcut
); }