You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
demoncord-rewrite/src/api/ui/settings/plugins.tsx

53 lines
1.5 KiB

//in theory this should never be unset? but just as a sanity check
//#ifnset _CORS_URL
//#set _CORS_URL = "https://cors.ruthenic.com/"
//#endif
import { React, nests, nestsReact } from "../../common";
import { add } from "../../plugin";
import webpack from "../../webpack";
import PlugCard from "./plugincard";
const Header = webpack.findByProps("Sizes", "Tags");
const FormDivider = webpack.findByDisplayName("FormDivider");
const Flex = webpack.findByDisplayName("Flex");
const TextInput = webpack.findByDisplayName("TextInput");
const Button = webpack.findByProps("BorderColors", "Colors");
export default () => {
const extNest: Nest<{ plugins: any }> = demon.summon("internal/nest");
const [input, setInput] = React.useState("");
nestsReact.useNest(extNest);
return (
<>
<Header size="demon-settings-header-size30">Plugins</Header>
<Flex basis="auto" grow={1} shrink={1}>
<TextInput
className="demon-settings-url"
placeholder="https://git.ruthenic.com/ruthenic/demoncord-noReplyMention/raw/branch/master/dist/plugin.js"
type="text"
value={input}
onChange={setInput}
onKeyDown={async (eve: { key: string }) => {
if (eve.key === "Enter") {
const text = await (
await fetch("$_CORS_URL" + input)
).text();
add(text);
setInput("");
}
}}
/>
</Flex>
<FormDivider className="demon-settings-divider" />
{Object.keys(extNest.ghost.plugins).map((k) => {
return (
<>
<PlugCard name={k} nest={extNest}></PlugCard>
</>
);
})}
</>
);
};