From a23655f3a7b86ef008b0344f78a3c8eeed32d741 Mon Sep 17 00:00:00 2001
From: thororen1234 <78185467+thororen1234@users.noreply.github.com>
Date: Wed, 22 May 2024 09:38:00 -0400
Subject: [PATCH] revert to a revert
---
src/plugins/fakeProfileThemes/index.css | 3 -
src/plugins/fakeProfileThemes/index.tsx | 255 ------------------------
2 files changed, 258 deletions(-)
delete mode 100644 src/plugins/fakeProfileThemes/index.css
delete mode 100644 src/plugins/fakeProfileThemes/index.tsx
diff --git a/src/plugins/fakeProfileThemes/index.css b/src/plugins/fakeProfileThemes/index.css
deleted file mode 100644
index 1c9bebf2..00000000
--- a/src/plugins/fakeProfileThemes/index.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.vc-fpt-preview * {
- pointer-events: none;
-}
diff --git a/src/plugins/fakeProfileThemes/index.tsx b/src/plugins/fakeProfileThemes/index.tsx
deleted file mode 100644
index 7a6bda9a..00000000
--- a/src/plugins/fakeProfileThemes/index.tsx
+++ /dev/null
@@ -1,255 +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 .
-*/
-
-// This plugin is a port from Alyxia's Vendetta plugin
-import "./index.css";
-
-import { definePluginSettings } from "@api/Settings";
-import ErrorBoundary from "@components/ErrorBoundary";
-import { Devs } from "@utils/constants";
-import { Margins } from "@utils/margins";
-import { classes, copyWithToast } from "@utils/misc";
-import { useAwaiter } from "@utils/react";
-import definePlugin, { OptionType } from "@utils/types";
-import { extractAndLoadChunksLazy, findComponentByCodeLazy } from "@webpack";
-import { Button, Flex, Forms, React, Text, UserProfileStore, UserStore, useState } from "@webpack/common";
-import { User } from "discord-types/general";
-import virtualMerge from "virtual-merge";
-
-interface UserProfile extends User {
- themeColors?: Array;
-}
-
-interface Colors {
- primary: number;
- accent: number;
-}
-
-function encode(primary: number, accent: number): string {
- const message = `[#${primary.toString(16).padStart(6, "0")},#${accent.toString(16).padStart(6, "0")}]`;
- const padding = "";
- const encoded = Array.from(message)
- .map(x => x.codePointAt(0))
- .filter(x => x! >= 0x20 && x! <= 0x7f)
- .map(x => String.fromCodePoint(x! + 0xe0000))
- .join("");
-
- return (padding || "") + " " + encoded;
-}
-
-// Courtesy of Cynthia.
-function decode(bio: string): Array | null {
- if (bio == null) return null;
-
- const colorString = bio.match(
- /\u{e005b}\u{e0023}([\u{e0061}-\u{e0066}\u{e0041}-\u{e0046}\u{e0030}-\u{e0039}]+?)\u{e002c}\u{e0023}([\u{e0061}-\u{e0066}\u{e0041}-\u{e0046}\u{e0030}-\u{e0039}]+?)\u{e005d}/u,
- );
- if (colorString != null) {
- const parsed = [...colorString[0]]
- .map(x => String.fromCodePoint(x.codePointAt(0)! - 0xe0000))
- .join("");
- const colors = parsed
- .substring(1, parsed.length - 1)
- .split(",")
- .map(x => parseInt(x.replace("#", "0x"), 16));
-
- return colors;
- } else {
- return null;
- }
-}
-
-const settings = definePluginSettings({
- nitroFirst: {
- description: "Default color source if both are present",
- type: OptionType.SELECT,
- options: [
- { label: "Nitro colors", value: true, default: true },
- { label: "Fake colors", value: false },
- ]
- }
-});
-
-interface ColorPickerProps {
- color: number | null;
- label: React.ReactElement;
- showEyeDropper?: boolean;
- suggestedColors?: string[];
- onChange(value: number | null): void;
-}
-
-// I can't be bothered to figure out the semantics of this component. The
-// functions surely get some event argument sent to them and they likely aren't
-// all required. If anyone who wants to use this component stumbles across this
-// code, you'll have to do the research yourself.
-interface ProfileModalProps {
- user: User;
- pendingThemeColors: [number, number];
- onAvatarChange: () => void;
- onBannerChange: () => void;
- canUsePremiumCustomization: boolean;
- hideExampleButton: boolean;
- hideFakeActivity: boolean;
- isTryItOutFlow: boolean;
-}
-
-const ColorPicker = findComponentByCodeLazy(".Messages.USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR", ".BACKGROUND_PRIMARY)");
-const ProfileModal = findComponentByCodeLazy('"ProfileCustomizationPreview"');
-
-const requireColorPicker = extractAndLoadChunksLazy(["USER_SETTINGS_PROFILE_COLOR_DEFAULT_BUTTON.format"], /createPromise:\(\)=>\i\.\i\("(.+?)"\).then\(\i\.bind\(\i,"(.+?)"\)\)/);
-
-export default definePlugin({
- name: "FakeProfileThemes",
- description: "Allows profile theming by hiding the colors in your bio thanks to invisible 3y3 encoding",
- authors: [Devs.Alyxia, Devs.Remty],
- patches: [
- {
- find: "UserProfileStore",
- replacement: {
- match: /(?<=getUserProfile\(\i\){return )(\i\[\i\])/,
- replace: "$self.colorDecodeHook($1)"
- }
- },
- {
- find: ".USER_SETTINGS_RESET_PROFILE_THEME",
- replacement: {
- match: /RESET_PROFILE_THEME}\)(?<=color:(\i),.{0,500}?color:(\i),.{0,500}?)/,
- replace: "$&,$self.addCopy3y3Button({primary:$1,accent:$2})"
- }
- }
- ],
- settingsAboutComponent: () => {
- const existingColors = decode(
- UserProfileStore.getUserProfile(UserStore.getCurrentUser().id).bio
- ) ?? [0, 0];
- const [color1, setColor1] = useState(existingColors[0]);
- const [color2, setColor2] = useState(existingColors[1]);
-
- const [, , loadingColorPickerChunk] = useAwaiter(requireColorPicker);
-
- return (
-
- Usage
-
- After enabling this plugin, you will see custom colors in
- the profiles of other people using compatible plugins.{" "}
-
- To set your own colors:
-
- -
- • use the color pickers below to choose your colors
-
- - • click the "Copy 3y3" button
- - • paste the invisible text anywhere in your bio
-
-
- Color pickers
- {!loadingColorPickerChunk && (
-
-
- Primary
-
- }
- onChange={(color: number) => {
- setColor1(color);
- }}
- />
-
- Accent
-
- }
- onChange={(color: number) => {
- setColor2(color);
- }}
- />
-
-
- )}
-
- Preview
-
-
{ }}
- onBannerChange={() => { }}
- canUsePremiumCustomization={true}
- hideExampleButton={true}
- hideFakeActivity={true}
- isTryItOutFlow={true}
- />
-
-
- );
- },
- settings,
- colorDecodeHook(user: UserProfile) {
- if (user) {
- // don't replace colors if already set with nitro
- if (settings.store.nitroFirst && user.themeColors) return user;
- const colors = decode(user.bio);
- if (colors) {
- return virtualMerge(user, {
- premiumType: 2,
- themeColors: colors
- });
- }
- }
- return user;
- },
- addCopy3y3Button: ErrorBoundary.wrap(function ({ primary, accent }: Colors) {
- return ;
- }, { noop: true }),
-});