aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/invisiblechat
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/invisiblechat')
-rw-r--r--src/plugins/invisiblechat/components/DecryptionModal.tsx77
-rw-r--r--src/plugins/invisiblechat/components/EncryptionModal.tsx116
-rw-r--r--src/plugins/invisiblechat/index.tsx213
3 files changed, 0 insertions, 406 deletions
diff --git a/src/plugins/invisiblechat/components/DecryptionModal.tsx b/src/plugins/invisiblechat/components/DecryptionModal.tsx
deleted file mode 100644
index 7d70444..0000000
--- a/src/plugins/invisiblechat/components/DecryptionModal.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Vencord, a modification for Discord's desktop app
- * Copyright (c) 2023 Vendicated and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
-*/
-
-import {
- ModalContent,
- ModalFooter,
- ModalHeader,
- ModalRoot,
- openModal,
-} from "@utils/modal";
-import { Button, Forms, React, TextInput } from "@webpack/common";
-
-import { decrypt } from "../index";
-
-export function DecModal(props: any) {
- const secret: string = props?.message?.content;
- const [password, setPassword] = React.useState("password");
-
- return (
- <ModalRoot {...props}>
- <ModalHeader>
- <Forms.FormTitle tag="h4">Decrypt Message</Forms.FormTitle>
- </ModalHeader>
-
- <ModalContent>
- <Forms.FormTitle tag="h5" style={{ marginTop: "10px" }}>Secret</Forms.FormTitle>
- <TextInput defaultValue={secret} disabled={true}></TextInput>
- <Forms.FormTitle tag="h5">Password</Forms.FormTitle>
- <TextInput
- style={{ marginBottom: "20px" }}
- onChange={setPassword}
- />
- </ModalContent>
-
- <ModalFooter>
- <Button
- color={Button.Colors.GREEN}
- onClick={() => {
- const toSend = decrypt(secret, password);
- if (!toSend || !props?.message) return;
- // @ts-expect-error
- Vencord.Plugins.plugins.InvisibleChat.buildEmbed(props?.message, toSend);
- props.onClose();
- }}>
- Decrypt
- </Button>
- <Button
- color={Button.Colors.TRANSPARENT}
- look={Button.Looks.LINK}
- style={{ left: 15, position: "absolute" }}
- onClick={props.onClose}
- >
- Cancel
- </Button>
- </ModalFooter>
- </ModalRoot>
- );
-}
-
-export function buildDecModal(msg: any): any {
- openModal((props: any) => <DecModal {...props} {...msg} />);
-}
diff --git a/src/plugins/invisiblechat/components/EncryptionModal.tsx b/src/plugins/invisiblechat/components/EncryptionModal.tsx
deleted file mode 100644
index f650f28..0000000
--- a/src/plugins/invisiblechat/components/EncryptionModal.tsx
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Vencord, a modification for Discord's desktop app
- * Copyright (c) 2023 Vendicated and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
-*/
-
-import {
- ModalContent,
- ModalFooter,
- ModalHeader,
- ModalProps,
- ModalRoot,
- openModal,
-} from "@utils/modal";
-import { findLazy } from "@webpack";
-import { Button, Forms, React, Switch, TextInput } from "@webpack/common";
-
-import { encrypt } from "../index";
-
-const ComponentDispatch = findLazy(m => m.emitter?._events?.INSERT_TEXT);
-
-function EncModal(props: ModalProps) {
- const [secret, setSecret] = React.useState("");
- const [cover, setCover] = React.useState("");
- const [password, setPassword] = React.useState("password");
- const [noCover, setNoCover] = React.useState(false);
-
- const isValid = secret && (noCover || (cover && /\w \w/.test(cover)));
-
- return (
- <ModalRoot {...props}>
- <ModalHeader>
- <Forms.FormTitle tag="h4">Encrypt Message</Forms.FormTitle>
- </ModalHeader>
-
- <ModalContent>
- <Forms.FormTitle tag="h5" style={{ marginTop: "10px" }}>Secret</Forms.FormTitle>
- <TextInput
- onChange={(e: string) => {
- setSecret(e);
- }}
- />
- <Forms.FormTitle tag="h5" style={{ marginTop: "10px" }}>Cover (2 or more Words!!)</Forms.FormTitle>
- <TextInput
- disabled={noCover}
- onChange={(e: string) => {
- setCover(e);
- }}
- />
- <Forms.FormTitle tag="h5" style={{ marginTop: "10px" }}>Password</Forms.FormTitle>
- <TextInput
- style={{ marginBottom: "20px" }}
- defaultValue={"password"}
- onChange={(e: string) => {
- setPassword(e);
- }}
- />
- <Switch
- value={noCover}
- onChange={(e: boolean) => {
- setNoCover(e);
- }}
- >
- Don't use a Cover
- </Switch>
- </ModalContent>
-
- <ModalFooter>
- <Button
- color={Button.Colors.GREEN}
- disabled={!isValid}
- onClick={() => {
- if (!isValid) return;
- const encrypted = encrypt(secret, password, noCover ? "d d" : cover);
- const toSend = noCover ? encrypted.replaceAll("d", "") : encrypted;
- if (!toSend) return;
-
- ComponentDispatch.dispatchToLastSubscribed("INSERT_TEXT", {
- rawText: `${toSend}`
- });
-
- props.onClose();
- }}
- >
- Send
- </Button>
- <Button
- color={Button.Colors.TRANSPARENT}
- look={Button.Looks.LINK}
- style={{ left: 15, position: "absolute" }}
- onClick={() => {
- props.onClose();
- }}
- >
- Cancel
- </Button>
- </ModalFooter>
- </ModalRoot>
- );
-}
-
-export function buildEncModal(): any {
- openModal(props => <EncModal {...props} />);
-}
diff --git a/src/plugins/invisiblechat/index.tsx b/src/plugins/invisiblechat/index.tsx
deleted file mode 100644
index 89d2d61..0000000
--- a/src/plugins/invisiblechat/index.tsx
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Vencord, a modification for Discord's desktop app
- * Copyright (c) 2023 Vendicated and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
-*/
-
-import { addButton, removeButton } from "@api/MessagePopover";
-import ErrorBoundary from "@components/ErrorBoundary";
-import { Devs } from "@utils/constants";
-import { getStegCloak } from "@utils/dependencies";
-import definePlugin from "@utils/types";
-import { findByPropsLazy } from "@webpack";
-import { Button, ButtonLooks, ChannelStore, FluxDispatcher, Tooltip } from "@webpack/common";
-
-import { buildDecModal } from "./components/DecryptionModal";
-import { buildEncModal } from "./components/EncryptionModal";
-
-const ButtonWrapperClasses = findByPropsLazy("buttonWrapper", "buttonContent");
-
-let steggo: any;
-
-function PopOverIcon() {
- return (
-
- <svg
- fill="var(--header-secondary)"
- width={24} height={24}
- viewBox={"0 0 64 64"}
- >
- <path d="M 32 9 C 24.832 9 19 14.832 19 22 L 19 27.347656 C 16.670659 28.171862 15 30.388126 15 33 L 15 49 C 15 52.314 17.686 55 21 55 L 43 55 C 46.314 55 49 52.314 49 49 L 49 33 C 49 30.388126 47.329341 28.171862 45 27.347656 L 45 22 C 45 14.832 39.168 9 32 9 z M 32 13 C 36.963 13 41 17.038 41 22 L 41 27 L 23 27 L 23 22 C 23 17.038 27.037 13 32 13 z" />
- </svg>
- );
-}
-
-
-function Indicator() {
- return (
- <Tooltip text="This message has a hidden message! (InvisibleChat)">
- {({ onMouseEnter, onMouseLeave }) => (
- <img
- aria-label="Hidden Message Indicator (InvisibleChat)"
- onMouseEnter={onMouseEnter}
- onMouseLeave={onMouseLeave}
- src="https://github.com/SammCheese/invisible-chat/raw/NewReplugged/src/assets/lock.png"
- width={20}
- height={20}
- style={{ transform: "translateY(4p)", paddingInline: 4 }}
- />
- )}
- </Tooltip>
-
- );
-
-}
-
-function ChatBarIcon() {
- return (
- <Tooltip text="Encrypt Message">
- {({ onMouseEnter, onMouseLeave }) => (
- // size="" = Button.Sizes.NONE
- <Button
- aria-haspopup="dialog"
- aria-label="Encrypt Message"
- size=""
- look={ButtonLooks.BLANK}
- onMouseEnter={onMouseEnter}
- onMouseLeave={onMouseLeave}
- innerClassName={ButtonWrapperClasses.button}
- onClick={() => buildEncModal()}
- style={{ marginRight: "2px" }}
- >
- <div className={ButtonWrapperClasses.buttonWrapper}>
- <svg
- aria-hidden
- role="img"
- width="24"
- height="24"
- viewBox={"0 0 64 64"}
- style={{ scale: "1.1" }}
- >
- <path fill="currentColor" d="M 32 9 C 24.832 9 19 14.832 19 22 L 19 27.347656 C 16.670659 28.171862 15 30.388126 15 33 L 15 49 C 15 52.314 17.686 55 21 55 L 43 55 C 46.314 55 49 52.314 49 49 L 49 33 C 49 30.388126 47.329341 28.171862 45 27.347656 L 45 22 C 45 14.832 39.168 9 32 9 z M 32 13 C 36.963 13 41 17.038 41 22 L 41 27 L 23 27 L 23 22 C 23 17.038 27.037 13 32 13 z" />
- </svg>
- </div>
- </Button>
- )}
- </Tooltip>
- );
-}
-
-
-export default definePlugin({
- name: "InvisibleChat",
- description: "Encrypt your Messages in a non-suspicious way! This plugin makes requests to >>https://embed.sammcheese.net<< to provide embeds to decrypted links!",
- authors: [Devs.SammCheese],
- patches: [
- {
- // Indicator
- find: ".Messages.MESSAGE_EDITED,",
- replacement: {
- match: /var .,.,.=(.)\.className,.=.\.message,.=.\.children,.=.\.content,.=.\.onUpdate/gm,
- replace: "try {$1 && $self.INV_REGEX.test($1.content[0]) ? $1.content.push($self.indicator()) : null } catch {};$&"
- }
- },
- {
- find: ".activeCommandOption",
- replacement: {
- match: /.=.\.activeCommand,.=.\.activeCommandOption,.{1,133}(.)=\[\];/,
- replace: "$&;$1.push($self.chatBarIcon());",
- }
- },
- ],
-
- EMBED_API_URL: "https://embed.sammcheese.net",
- INV_REGEX: new RegExp(/( \u200c|\u200d |[\u2060-\u2064])[^\u200b]/),
- URL_REGEX: new RegExp(
- /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/,
- ),
-
- async start() {
- const { default: StegCloak } = await getStegCloak();
- steggo = new StegCloak(true, false);
-
- addButton("invDecrypt", message => {
- return this.INV_REGEX.test(message?.content)
- ? {
- label: "Decrypt Message",
- icon: this.popOverIcon,
- message: message,
- channel: ChannelStore.getChannel(message.channel_id),
- onClick: () => buildDecModal({ message })
- }
- : null;
- });
- },
-
- stop() {
- removeButton("invDecrypt");
- },
-
- // Gets the Embed of a Link
- async getEmbed(url: URL): Promise<Object | {}> {
- const controller = new AbortController();
- const timeout = setTimeout(() => controller.abort(), 5000);
-
- const options: RequestInit = {
- signal: controller.signal,
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({
- url,
- }),
- };
-
- // AWS hosted url to discord embed object
- const rawRes = await fetch(this.EMBED_API_URL, options);
- clearTimeout(timeout);
-
- return await rawRes.json();
- },
-
- async buildEmbed(message: any, revealed: string): Promise<void> {
- const urlCheck = revealed.match(this.URL_REGEX);
-
- message.embeds.push({
- type: "rich",
- title: "Decrypted Message",
- color: "0x45f5f5",
- description: revealed,
- footer: {
- text: "Made with ❤️ by c0dine and Sammy!",
- },
- });
-
- if (urlCheck?.length)
- message.embeds.push(await this.getEmbed(new URL(urlCheck[0])));
-
- this.updateMessage(message);
- },
-
- updateMessage: (message: any) => {
- FluxDispatcher.dispatch({
- type: "MESSAGE_UPDATE",
- message,
- });
- },
-
- chatBarIcon: ErrorBoundary.wrap(ChatBarIcon, { noop: true }),
- popOverIcon: () => <PopOverIcon />,
- indicator: ErrorBoundary.wrap(Indicator, { noop: true })
-});
-
-export function encrypt(secret: string, password: string, cover: string): string {
- return steggo.hide(secret + "\u200b", password, cover);
-}
-
-export function decrypt(secret: string, password: string): string {
- return steggo.reveal(secret, password).replace("\u200b", "");
-}
-