Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
verticalsync committed Apr 25, 2024
2 parents 0b1ae76 + 6008aea commit a4dceff
Show file tree
Hide file tree
Showing 31 changed files with 6,284 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,22 @@ Visit [1_INSTALLING.md](/docs/1_INSTALLING.md)
- - QuestionMarkReplacement (for smuki, i think he's acoustic)
- - SmukiCommands (roblox tax calculation and profile commands for smuki)

- Plugins by [Tolgchu](https://github.com/Tolga1452/Vencord)
- - BetterShopPreview
- - GodMode
- - RepeatMessage
- - RunInConsole
- - SlashCommandMentionOptions
- - TalkInReverse

- PurgeMessages (by [bhop](https://github.com/prettylittlelies))
- PlatformSpoofer (by [drag](https://github.com/dragdotpng))
- Timezones (by [mantikafasi](https://github.com/mantikafasi) & [ArjixWasTaken](https://github.com/ArjixWasTaken))
- CustomScreenShare (by [KawaiianPizza](https://github.com/KawaiianPizza))
- iRememberYou (by [zoodogood](https://github.com/zoodogood/vencord-plugins))
- EmojiDownloader (by [woosh](https://github.com/w8y) modified version of ServerDownload by [cheesesamwich](https://github.com/cheesesamwich/ServerDownload))
- GlobalBadges (by [HypedDomi](https://github.com/domi-btnr/Vencord-Plugins))
- MessageLoggerEnhanced (by [Syncxv](https://github.com/Syncxv/vc-message-logger-enhanced))
- MessageLoggerEnhanced (by [Syncxv](https://github.com/Syncxv/vc-message-logger-enhanced))/
- CommandPalette (by [Ethan](https://github.com/ethan-davies)) (added from Ethan's [pull request](https://github.com/Vendicated/Vencord/pull/2145) to vencord)
- AllCallTimers (by [Max-Herbold](https://github.com/Max-Herbold)) (added from Max's [pull request](https://github.com/Vendicated/Vencord/pull/2132) to vencord)
- SoundBoardLogger (by [ImpishMoxxie](https://github.com/ImpishMoxxie/SoundBoardLogger))
Expand All @@ -66,6 +74,7 @@ Visit [1_INSTALLING.md](/docs/1_INSTALLING.md)
- AmITyping (by [MrDiamondDog](https://github.com/MrDiamondDog)) (added from MrDiamondDog's [pull request](https://github.com/Vendicated/Vencord/pull/2360))
- UserPFP (by [Nexpid](https://github.com/Nexpid)) (added from Nexpid's [pull request](https://github.com/Vendicated/Vencord/pull/1956))
- ShowBadgeInChat (by [KrstlSkll69](https://github.com/KrstlSkll69) (added from KrstlSkll69's [pull request](https://github.com/Vendicated/Vencord/pull/2347)))
- DiscordColorways (by [DaBluLite](https://github.com/DaBluLite/DiscordColorways))

</details>

Expand Down
88 changes: 88 additions & 0 deletions src/suncordplugins/betterShopPreview/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Vencord, a modification for Discord's desktop app
* Copyright (c) 2022 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 { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { UserStore, useState } from "@webpack/common";

let avatarUrl = "";

const settings = definePluginSettings({
default: {
type: OptionType.BOOLEAN,
description: "Enable avatar preview by default.",
default: true
}
});

function toggle(enabled: boolean) {
const avatars = document.querySelectorAll(".shopCard__3d319 .avatarContainer_e11d35 .wrapper__3ed10 .mask_d5067d foreignObject .avatarStack__789b4");

for (const avatar of avatars) {
const img = avatar.querySelector("img");

if (img) img.src = enabled ? avatarUrl : "https://canary.discord.com/assets/6d8f0708e196aaad2550.png";
}
}

const PreviewToggle = () => {
const [enabled, setEnabled] = useState(settings.store.default);

toggle(enabled);

return (
<button type="button" className="fieldButton__1edf0 button__581d0 lookFilled__950dd colorPrimary_ebe632 sizeSmall_da7d10 grow__4c8a4" style={{
marginLeft: "8px"
}} onClick={() => {
setEnabled(!enabled);
toggle(!enabled);
}}>
<div className="contents__322f4">
{enabled ? "Disable" : "Enable"} Avatar Preview
</div>
</button>
);
};

export default definePlugin({
name: "BetterShopPreview",
description: "Uses your avatar for avatar decoration previews in the Discord Shop.",
authors: [Devs.Tolgchu],
settings,
patches: [
{
find: "}),(0,l.jsx)(T.default.Title,{className:en.title,children:er.default.Messages.COLLECTIBLES_SHOP})]",
replacement: [{
match: "{className:en.title,children:er.default.Messages.COLLECTIBLES_SHOP}",
replace: "{className:en.title,children:[er.default.Messages.COLLECTIBLES_SHOP,$self.PreviewToggle()]}"
}]
}
],
PreviewToggle,
async start() {
const user = UserStore.getCurrentUser();
const url = `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.gif`;

await fetch(url).then(response => {
if (response.ok) avatarUrl = url;
else avatarUrl = url.replace(".gif", ".png");
});
},
stop() { }
});
220 changes: 220 additions & 0 deletions src/suncordplugins/discordColorways/components/ColorPicker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { Flex } from "@components/Flex";
import { CopyIcon } from "@components/Icons";
import {
ModalProps,
ModalRoot,
} from "@utils/modal";
import {
Button,
Clipboard,
ScrollerThin,
TextInput,
Toasts,
useState,
} from "@webpack/common";

import { colorVariables } from "../css";

interface ToolboxItem {
title: string;
onClick: () => void;
id?: string;
iconClassName?: string;
}

const ColorVarItems: ToolboxItem[] = colorVariables.map((colorVariable: string) => {
return {
title: "Copy " + colorVariable,
onClick: () => {
function getHex(str: string): string { return Object.assign(document.createElement("canvas").getContext("2d") as {}, { fillStyle: str }).fillStyle; }
Clipboard.copy(getHex(getComputedStyle(document.body).getPropertyValue("--" + colorVariable)));
Toasts.show({ message: "Color " + colorVariable + " copied to clipboard", id: "toolbox-color-var-copied", type: 1 });
},
id: colorVariable
};
});

const ToolboxItems: ToolboxItem[] = [
{
title: "Copy Accent Color",
onClick: () => {
function getHex(str: string): string {
return Object.assign(
document.createElement("canvas").getContext("2d") as {},
{ fillStyle: str }
).fillStyle;
}
Clipboard.copy(
getHex(
getComputedStyle(document.body).getPropertyValue(
"--brand-experiment"
)
)
);
Toasts.show({
message: "Accent color copied to clipboard",
id: "toolbox-accent-color-copied",
type: 1,
});
},
id: "colorways-toolbox_copy-accent",
iconClassName: "copy",
},
{
title: "Copy Primary Color",
onClick: () => {
function getHex(str: string): string {
return Object.assign(
document.createElement("canvas").getContext("2d") as {},
{ fillStyle: str }
).fillStyle;
}
Clipboard.copy(
getHex(
getComputedStyle(document.body).getPropertyValue(
"--background-primary"
)
)
);
Toasts.show({
message: "Primary color copied to clipboard",
id: "toolbox-primary-color-copied",
type: 1,
});
},
id: "colorways-toolbox_copy-primary",
iconClassName: "copy",
},
{
title: "Copy Secondary Color",
onClick: () => {
function getHex(str: string): string {
return Object.assign(
document.createElement("canvas").getContext("2d") as {},
{ fillStyle: str }
).fillStyle;
}
Clipboard.copy(
getHex(
getComputedStyle(document.body).getPropertyValue(
"--background-secondary"
)
)
);
Toasts.show({
message: "Secondary color copied to clipboard",
id: "toolbox-secondary-color-copied",
type: 1,
});
},
id: "colorways-toolbox_copy-secondary",
iconClassName: "copy",
},
{
title: "Copy Tertiary Color",
onClick: () => {
function getHex(str: string): string {
return Object.assign(
document.createElement("canvas").getContext("2d") as {},
{ fillStyle: str }
).fillStyle;
}
Clipboard.copy(
getHex(
getComputedStyle(document.body).getPropertyValue(
"--background-tertiary"
)
)
);
Toasts.show({
message: "Tertiary color copied to clipboard",
id: "toolbox-tertiary-color-copied",
type: 1,
});
},
id: "colorways-toolbox_copy-tertiary",
iconClassName: "copy",
}
];

export default function ({ modalProps }: { modalProps: ModalProps; }) {
const [colorVarItems, setColorVarItems] = useState<ToolboxItem[]>(ColorVarItems);
const [collapsedSettings, setCollapsedSettings] = useState<boolean>(true);
let results: ToolboxItem[];
function searchToolboxItems(e: string) {
results = [];
ColorVarItems.find((ToolboxItem: ToolboxItem) => {
if (ToolboxItem.title.toLowerCase().includes(e.toLowerCase())) {
results.push(ToolboxItem);
}
});
setColorVarItems(results);
}

return (
<ModalRoot {...modalProps} className="colorwayColorpicker">
<Flex style={{ gap: "8px", marginBottom: "8px" }}>
<TextInput
className="colorwaysColorpicker-search"
placeholder="Search for a color:"
onChange={e => {
searchToolboxItems(e);
if (e) {
setCollapsedSettings(false);
} else {
setCollapsedSettings(true);
}
}}
/>
<Button
innerClassName="colorwaysSettings-iconButtonInner"
size={Button.Sizes.ICON}
color={Button.Colors.TRANSPARENT}
onClick={() => setCollapsedSettings(!collapsedSettings)}
>
<svg width="32" height="24" viewBox="0 0 24 24" aria-hidden="true" role="img">
<path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M7 10L12 15 17 10" aria-hidden="true" />
</svg>
</Button>
</Flex>
<ScrollerThin style={{ color: "var(--text-normal)" }} orientation="vertical" className={collapsedSettings ? " colorwaysColorpicker-collapsed" : ""} paddingFix>
{colorVarItems.map((toolboxItem: ToolboxItem) => {
return (
<div
id={
"colorways-colorstealer-item_" +
toolboxItem.id
}
className="colorwaysCreator-settingItm colorwaysCreator-toolboxItm"
onClick={toolboxItem.onClick}
style={
{
"--brand-experiment":
"var(--" + toolboxItem.id + ")",
} as React.CSSProperties
}
>
{toolboxItem.title}
</div>
);
})}
</ScrollerThin>
<Flex style={{ justifyContent: "space-between", marginTop: "8px" }} wrap="wrap" className={collapsedSettings ? "" : " colorwaysColorpicker-collapsed"}>
{ToolboxItems.map((toolboxItem: ToolboxItem, i: number) => <div
id={toolboxItem.id || `colorways-toolbox_item-${i}`}
className="colorwayToolbox-listItem"
>
<CopyIcon onClick={toolboxItem.onClick} width={20} height={20} className="colorwayToolbox-listItemSVG" />
<span className="colorwaysToolbox-label">{toolboxItem.title}</span>
</div>
)}
</Flex>
</ModalRoot>
);
}
Loading

0 comments on commit a4dceff

Please sign in to comment.