import { ChangeEvent, useRef, useState, useEffect } from "react"; import "@styles/Generator.scss"; import Viewer from "./Viewer"; export default function Generator() { // State variables const [outputUrl, setOutputUrl] = useState(() => new URL(window.location.href).toString()); const copiedTooltipRef = useRef(null); const [remoteAppPort, setRemoteAppPort] = useState(5899); const [showChannelName, setShowChannelName] = useState(true); const [alignRight, setAlignRight] = useState(false); const [hideNonTalking, setHideNonTalking] = useState(false); const [clientLimit, setClientLimit] = useState(0); // Effect to generate URL when dependencies change useEffect(() => { generateUrl(); }, [remoteAppPort, showChannelName, hideNonTalking, clientLimit, alignRight]); // Function to generate the output URL function generateUrl() { const url = new URL(window.location.href); url.hash = ""; url.searchParams.set("remoteAppPort", remoteAppPort.toString()); url.searchParams.set("showChannelName", showChannelName.toString()); url.searchParams.set("hideNonTalking", hideNonTalking.toString()); url.searchParams.set("clientLimit", clientLimit.toString()); url.searchParams.set("alignRight", alignRight.toString()); // url.hash function always sets the hash to the end of the URL, so we have to replace the question mark with a hash // gh-pages needs the hash to be between the base URL and the search params setOutputUrl(url.toString().replace("?", "#/?")); } // Function to copy URL to clipboard function copy() { navigator.clipboard.writeText(outputUrl); if (copiedTooltipRef.current) { copiedTooltipRef.current.style.animation = "tooltipAnimation 200ms"; copiedTooltipRef.current.style.opacity = "1"; setTimeout(() => { if (copiedTooltipRef.current) { copiedTooltipRef.current.style.opacity = "0"; copiedTooltipRef.current.style.animation = ""; } }, 1000); } } return (
{/* Header */}

TeamSpeak-OBS-Overlay Generator

by DerTyp7

{/* Instructions */}

1. Customize your settings

2. Copy the generated URL

3. Paste the URL into the BrowserSource URL field in OBS

Click here for detailed instructions
{/* Output Section */}

{outputUrl}

Copied!
{/* Generator Content */}
{/* Configurations */}

Configurations

{/* Option Sections */}
{/* Show Channel Name Option */}
setShowChannelName(!showChannelName)}>
{/* Hide Non-Talking Clients Option */}
setHideNonTalking(!hideNonTalking)}>
{/* Alignment Option */}
setAlignRight(!alignRight)}>
{/* Client Limit Option */}
) => setClientLimit(parseInt(e.target.value))} />
{/* RemoteApp-Port Option */}
) => setRemoteAppPort(parseInt(e.target.value))} />
{/* Preview */}
); }