This commit is contained in:
thororen1234 2025-11-22 17:39:46 -05:00
parent fb7d14ce63
commit 3d21816a2f
No known key found for this signature in database
14 changed files with 218 additions and 202 deletions

View file

@ -112,42 +112,45 @@ export default definePlugin({
authors: [EquicordDevs.ThePirateStoner],
dependencies: ["MessagePopoverAPI"],
settings,
renderMessagePopoverButton(msg) {
const handleClick = () => {
const base64Strings = findBase64Strings(msg.content);
const decodedContent = decodeBase64Strings(base64Strings);
if (settings.store.clickMethod === "Right") {
decodedContent.forEach(content => copyWithToast(content));
} else {
openDecodedBase64Modal(decodedContent);
}
};
messagePopoverButton: {
icon: DecodeIcon,
render(msg) {
const handleClick = () => {
const base64Strings = findBase64Strings(msg.content);
const decodedContent = decodeBase64Strings(base64Strings);
if (settings.store.clickMethod === "Right") {
decodedContent.forEach(content => copyWithToast(content));
} else {
openDecodedBase64Modal(decodedContent);
}
};
const handleContextMenu = e => {
const base64Strings = findBase64Strings(msg.content);
const decodedContent = decodeBase64Strings(base64Strings);
if (settings.store.clickMethod === "Left") {
e.preventDefault();
e.stopPropagation();
decodedContent.forEach(content => copyWithToast(content));
} else {
e.preventDefault();
e.stopPropagation();
openDecodedBase64Modal(decodedContent);
}
};
const handleContextMenu = e => {
const base64Strings = findBase64Strings(msg.content);
const decodedContent = decodeBase64Strings(base64Strings);
if (settings.store.clickMethod === "Left") {
e.preventDefault();
e.stopPropagation();
decodedContent.forEach(content => copyWithToast(content));
} else {
e.preventDefault();
e.stopPropagation();
openDecodedBase64Modal(decodedContent);
}
};
const label = settings.store.clickMethod === "Right"
? "Copy Decoded (Left Click) / Decode Base64 (Right Click)"
: "Decode Base64 (Left Click) / Copy Decoded (Right Click)";
const label = settings.store.clickMethod === "Right"
? "Copy Decoded (Left Click) / Decode Base64 (Right Click)"
: "Decode Base64 (Left Click) / Copy Decoded (Right Click)";
return {
label,
icon: DecodeIcon,
message: msg,
channel: ChannelStore.getChannel(msg.channel_id),
onClick: handleClick,
onContextMenu: handleContextMenu
};
return {
label,
icon: DecodeIcon,
message: msg,
channel: ChannelStore.getChannel(msg.channel_id),
onClick: handleClick,
onContextMenu: handleContextMenu
};
}
}
});

View file

@ -226,7 +226,7 @@ export function buildThemeMenuEntries() {
<Menu.MenuCheckboxItem
id={`theme-${theme.fileName}`}
key={theme.fileName}
label={theme.name}
label={theme.fileName}
checked={enabledThemes.includes(theme.fileName)}
action={() => {
if (enabledThemes.includes(theme.fileName)) {

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
import { removeMessagePopoverButton } from "@api/MessagePopover";
import { definePluginSettings } from "@api/Settings";
import { disableStyle, enableStyle } from "@api/Styles";
import { Devs } from "@utils/constants";
@ -94,9 +94,9 @@ export default definePlugin({
description: "Jumps to the earliest reply to a message in a channel (lets you follow past conversations more easily).",
authors: [Devs.newwares],
settings,
start() {
enableStyle(styles);
addMessagePopoverButton("vc-findreply", message => {
messagePopoverButton: {
icon: FindReplyIcon,
render(message) {
if (!message.id) return null;
const replies = findReplies(message);
if (settings.store.hideButtonIfNoReply && !replies.length) return null;
@ -148,7 +148,10 @@ export default definePlugin({
}
}
};
});
}
},
start() {
enableStyle(styles);
},
stop() {
removeMessagePopoverButton("vc-findreply");

View file

@ -20,7 +20,7 @@ import "./style.css";
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { DataStore } from "@api/index";
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
import { removeMessagePopoverButton } from "@api/MessagePopover";
import ErrorBoundary from "@components/ErrorBoundary";
import { EquicordDevs } from "@utils/constants";
import { classes } from "@utils/misc";
@ -112,11 +112,9 @@ export default definePlugin({
e.toolbar,
];
},
async start() {
if (await DataStore.keys(HolyNoteStore).then(keys => !keys.includes("Main"))) return noteHandler.newNoteBook("Main");
if (!noteHandlerCache.has("Main")) await DataStoreToCache();
addMessagePopoverButton("HolyNotes", message => {
messagePopoverButton: {
icon: NoteButtonPopover,
render(message) {
return {
label: "Save Note",
icon: NoteButtonPopover,
@ -125,7 +123,11 @@ export default definePlugin({
onClick: () => noteHandler.addNote(message, "Main")
};
});
}
},
async start() {
if (await DataStore.keys(HolyNoteStore).then(keys => !keys.includes("Main"))) return noteHandler.newNoteBook("Main");
if (!noteHandlerCache.has("Main")) await DataStoreToCache();
},
async stop() {

View file

@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import { classes } from "@utils/misc";
@ -70,40 +69,44 @@ export function Husk(props: IconProps) {
);
}
const settings = definePluginSettings({
findInServer: {
description: "Attempt to find emoji of same name in server before using ID in settings (useful if no nitro)",
type: OptionType.BOOLEAN,
default: true
},
emojiName: {
description: "Emoji name (default (from Vencord Server): husk)",
type: OptionType.STRING,
default: "husk"
},
emojiID: {
description: "Emoji ID (default (from Vencord Server): 1026532993923293184)",
type: OptionType.BIGINT,
default: 1026532993923293184n
}
});
function getEmojiIdThatShouldBeUsed(guildId: string) {
if (!settings.store.findInServer || guildId === "") return settings.store.emojiID;
let id = "";
EmojiStore.getGuildEmoji(guildId).forEach(emoji => {
if (emoji.name === settings.store.emojiName) {
id = emoji.id;
}
});
return id !== "" ? id : settings.store.emojiID;
}
export default definePlugin({
name: "Husk",
description: "Adds Husk button (check settings to change used emoji)",
authors: [Devs.nin0dev],
dependencies: ["MessagePopoverAPI"],
settings: definePluginSettings({
findInServer: {
description: "Attempt to find emoji of same name in server before using ID in settings (useful if no nitro)",
type: OptionType.BOOLEAN,
default: true
},
emojiName: {
description: "Emoji name (default (from Vencord Server): husk)",
type: OptionType.STRING,
default: "husk"
},
emojiID: {
description: "Emoji ID (default (from Vencord Server): 1026532993923293184)",
type: OptionType.BIGINT,
default: 1026532993923293184n
}
}),
getEmojiIdThatShouldBeUsed(guildId: string) {
if (!this.settings.store.findInServer || guildId === "") return this.settings.store.emojiID;
let id = "";
EmojiStore.getGuildEmoji(guildId).forEach(emoji => {
if (emoji.name === this.settings.store.emojiName) {
id = emoji.id;
}
});
return id !== "" ? id : this.settings.store.emojiID;
},
async start() {
addMessagePopoverButton("Husk", msg => {
settings,
messagePopoverButton: {
icon: Husk,
render(msg) {
return {
label: "Husk",
icon: Husk,
@ -112,16 +115,11 @@ export default definePlugin({
onClick: () => {
const guildId = ChannelStore.getChannel(msg.channel_id).guild_id !== null ? ChannelStore.getChannel(msg.channel_id).guild_id : "";
RestAPI.put({
url: `/channels/${msg.channel_id}/messages/${msg.id}/reactions/${this.settings.store.emojiName}:${this.getEmojiIdThatShouldBeUsed(guildId)}/@me`
url: `/channels/${msg.channel_id}/messages/${msg.id}/reactions/${settings.store.emojiName}:${getEmojiIdThatShouldBeUsed(guildId)}/@me`
}
);
}
};
});
},
stop() {
removeMessagePopoverButton("Husk");
},
},
}
});

View file

@ -26,7 +26,7 @@ import {
} from "@utils/modal";
import { Button, React, TextInput } from "@webpack/common";
import invisibleChatDesktop, { decrypt } from "../index";
import { buildEmbed, decrypt } from "../index";
export function DecModal(props: any) {
const encryptedMessage: string = props?.message?.content;
@ -54,7 +54,7 @@ export function DecModal(props: any) {
onClick={() => {
const toSend = decrypt(encryptedMessage, password, true);
if (!toSend || !props?.message) return;
invisibleChatDesktop.buildEmbed(props?.message, toSend);
buildEmbed(props?.message, toSend);
props.onClose();
}}>
Decrypt

View file

@ -98,6 +98,49 @@ const settings = definePluginSettings({
}
});
const EMBED_API_URL = "https://embed.sammcheese.net";
const INV_REGEX = new RegExp(/( \u200c|\u200d |[\u2060-\u2064])[^\u200b]/);
const URL_REGEX = new RegExp(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/);
function colorCodeFromNumber(color: number): string {
return `#${[color >> 16, color >> 8, color]
.map(x => (x & 0xFF).toString(16))
.join("")}`;
}
async function getEmbed(url: URL): Promise<Object | {}> {
const { body } = await RestAPI.post({
url: Constants.Endpoints.UNFURL_EMBED_URLS,
body: {
urls: [url]
}
});
// The endpoint returns the color as a number, but Discord expects a string
body.embeds[0].color = colorCodeFromNumber(body.embeds[0].color);
return await body.embeds[0];
}
export async function buildEmbed(message: any, revealed: string): Promise<void> {
const urlCheck = revealed.match(URL_REGEX);
message.embeds.push({
type: "rich",
rawTitle: "Decrypted Message",
color: "#45f5f5",
rawDescription: revealed,
footer: {
text: "Made with ❤️ by c0dine and Sammy!",
},
});
if (urlCheck?.length) {
const embed = await getEmbed(new URL(urlCheck[0]));
if (embed)
message.embeds.push(embed);
}
updateMessage(message.channel_id, message.id, { embeds: message.embeds });
}
export default definePlugin({
name: "InvisibleChat",
description: "Encrypt your Messages in a non-suspicious way!",
@ -116,80 +159,35 @@ export default definePlugin({
}
},
],
INV_REGEX,
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);
},
renderMessagePopoverButton(message) {
return this.INV_REGEX.test(message?.content)
? {
label: "Decrypt Message",
icon: this.popOverIcon,
message: message,
channel: ChannelStore.getChannel(message.channel_id),
onClick: async () => {
const res = await iteratePasswords(message);
if (res)
this.buildEmbed(message, res);
else
buildDecModal({ message });
}
}
: null;
},
renderChatBarButton: ChatBarIcon,
messagePopoverButton: {
icon: PopOverIcon,
render(message) {
return INV_REGEX.test(message?.content)
? {
label: "Decrypt Message",
icon: PopOverIcon,
message: message,
channel: ChannelStore.getChannel(message.channel_id),
onClick: async () => {
const res = await iteratePasswords(message);
colorCodeFromNumber(color: number): string {
return `#${[color >> 16, color >> 8, color]
.map(x => (x & 0xFF).toString(16))
.join("")}`;
},
// Gets the Embed of a Link
async getEmbed(url: URL): Promise<Object | {}> {
const { body } = await RestAPI.post({
url: Constants.Endpoints.UNFURL_EMBED_URLS,
body: {
urls: [url]
}
});
// The endpoint returns the color as a number, but Discord expects a string
body.embeds[0].color = this.colorCodeFromNumber(body.embeds[0].color);
return await body.embeds[0];
},
async buildEmbed(message: any, revealed: string): Promise<void> {
const urlCheck = revealed.match(this.URL_REGEX);
message.embeds.push({
type: "rich",
rawTitle: "Decrypted Message",
color: "#45f5f5",
rawDescription: revealed,
footer: {
text: "Made with ❤️ by c0dine and Sammy!",
},
});
if (urlCheck?.length) {
const embed = await this.getEmbed(new URL(urlCheck[0]));
if (embed)
message.embeds.push(embed);
if (res)
buildEmbed(message, res);
else
buildDecModal({ message });
}
}
: null;
}
updateMessage(message.channel_id, message.id, { embeds: message.embeds });
},
popOverIcon: () => <PopOverIcon />,
indicator: ErrorBoundary.wrap(Indicator, { noop: true })
});

View file

@ -136,15 +136,18 @@ export default definePlugin({
contextMenus: {
"message": messageCtxPatch
},
renderMessagePopoverButton(msg) {
if (!msg) return null;
return {
label: "Repeat (Click) / Repeat and Reply (Shift + Click)",
icon: RepeatMessageIcon,
message: msg,
channel: ChannelStore.getChannel(msg.channel_id),
onClick: async () => repeatMessage(msg)
};
messagePopoverButton: {
icon: RepeatMessageIcon,
render(msg) {
if (!msg) return null;
return {
label: "Repeat (Click) / Repeat and Reply (Shift + Click)",
icon: RepeatMessageIcon,
message: msg,
channel: ChannelStore.getChannel(msg.channel_id),
onClick: async () => repeatMessage(msg)
};
}
},
start() {
document.addEventListener("keyup", keyupListener);

View file

@ -4,12 +4,10 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { ChatBarButton, ChatBarButtonFactory } from "@api/ChatButtons";
import { cl } from "@equicordplugins/soundBoardLogger/utils";
import { classes } from "@utils/misc";
import { Button, ButtonWrapperClasses, Tooltip } from "@webpack/common";
import { openSoundBoardLog } from "./SoundBoardLog";
// Thanks svgrepo.com for the play and download icons.
// Licensed under CC Attribution License https://www.svgrepo.com/page/licensing/#CC%20Attribution
@ -58,12 +56,8 @@ export function IconWithTooltip({ text, icon, onClick }) {
</Tooltip>;
}
export const ChatBarIcon: ChatBarButtonFactory = ({ isMainChat }) => {
if (!isMainChat) return null;
return (
<ChatBarButton tooltip="Open SoundBoard Log"
onClick={openSoundBoardLog}>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" className="chatBarLogIcon" viewBox="1.134 10.59 87.732 68.821"><path fill="currentColor" d="M84.075 10.597 5.932 10.59a4.799 4.799 0 0 0-4.798 4.79v59.226a4.801 4.801 0 0 0 4.798 4.798l78.144.007a4.79 4.79 0 0 0 4.79-4.794V15.391a4.796 4.796 0 0 0-4.791-4.794zm-11.704 8.766c0-.283.229-.509.51-.509h7.105c.279 0 .501.226.501.509v7.102c0 .28-.222.509-.501.509h-7.105a.511.511 0 0 1-.51-.509v-7.102zm-63.968 0c0-.283.229-.509.509-.509h29.399c.28 0 .502.226.502.509v7.102c0 .28-.222.509-.502.509H8.912a.51.51 0 0 1-.509-.509v-7.102zm7.863 45.454a.727.727 0 0 1-.727.727H14.28v6.466c0 1-.822 1.821-1.829 1.821-.516 0-.97-.199-1.301-.53a1.829 1.829 0 0 1-.531-1.291v-6.466H9.51a.726.726 0 0 1-.727-.727v-6.854c0-.4.327-.727.727-.727h1.11V37.583c0-1.017.822-1.839 1.832-1.839.505 0 .96.211 1.291.542a1.8 1.8 0 0 1 .538 1.297v19.653h1.259c.4 0 .727.326.727.727v6.854zm11.02-13.204a.73.73 0 0 1-.727.728h-1.11v19.651a1.835 1.835 0 0 1-1.832 1.839c-.506 0-.96-.21-1.291-.541a1.8 1.8 0 0 1-.538-1.298V52.341H20.53a.73.73 0 0 1-.727-.728v-6.855c0-.403.327-.727.727-.727h1.259v-6.466a1.83 1.83 0 0 1 1.829-1.821c.516 0 .97.2 1.301.531.331.331.531.792.531 1.29v6.466h1.11c.4 0 .727.324.727.727v6.855zm11.268 13.204a.727.727 0 0 1-.727.727h-1.259v6.466c0 1-.821 1.821-1.829 1.821-.516 0-.97-.199-1.301-.53a1.828 1.828 0 0 1-.53-1.291v-6.466h-1.11a.726.726 0 0 1-.727-.727v-6.854c0-.4.327-.727.727-.727h1.11V37.583c0-1.017.821-1.839 1.832-1.839.505 0 .959.211 1.291.542a1.8 1.8 0 0 1 .538 1.297v19.653h1.259c.4 0 .727.326.727.727v6.854zm10.94-13.204a.73.73 0 0 1-.728.728h-1.11v19.651a1.835 1.835 0 0 1-1.832 1.839 1.82 1.82 0 0 1-1.29-.541 1.802 1.802 0 0 1-.539-1.298V52.341h-1.259a.73.73 0 0 1-.727-.728v-6.855c0-.403.327-.727.727-.727h1.259v-6.466c0-.999.822-1.821 1.829-1.821.516 0 .97.2 1.301.531.331.331.53.792.53 1.29v6.466h1.11c.4 0 .728.324.728.727v6.855zm8.703-32.25c0-.283.229-.509.508-.509h7.106c.279 0 .501.226.501.509v7.102c0 .28-.222.509-.501.509h-7.106a.51.51 0 0 1-.508-.509v-7.102zm4.176 53.927a4.083 4.083 0 0 1-4.082-4.082c0-2.25 1.828-4.078 4.082-4.078s4.078 1.828 4.078 4.078a4.08 4.08 0 0 1-4.078 4.082zm0-14.709a4.082 4.082 0 1 1 0-8.163 4.078 4.078 0 0 1 4.078 4.081 4.08 4.08 0 0 1-4.078 4.082zm0-14.713a4.082 4.082 0 0 1-4.082-4.081 4.08 4.08 0 0 1 8.16 0 4.079 4.079 0 0 1-4.078 4.081zM76.438 73.29a4.082 4.082 0 0 1-4.081-4.082 4.081 4.081 0 0 1 4.081-4.078 4.078 4.078 0 0 1 4.078 4.078 4.078 4.078 0 0 1-4.078 4.082zm0-14.709a4.081 4.081 0 0 1 0-8.163 4.078 4.078 0 0 1 4.078 4.081 4.08 4.08 0 0 1-4.078 4.082zm0-14.713a4.082 4.082 0 0 1-4.081-4.081 4.08 4.08 0 0 1 8.159 0 4.078 4.078 0 0 1-4.078 4.081z" /></svg>
</ChatBarButton>
);
export const ChatBarIcon = () => {
return <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" className="chatBarLogIcon" viewBox="1.134 10.59 87.732 68.821">
<path fill="currentColor" d="M84.075 10.597 5.932 10.59a4.799 4.799 0 0 0-4.798 4.79v59.226a4.801 4.801 0 0 0 4.798 4.798l78.144.007a4.79 4.79 0 0 0 4.79-4.794V15.391a4.796 4.796 0 0 0-4.791-4.794zm-11.704 8.766c0-.283.229-.509.51-.509h7.105c.279 0 .501.226.501.509v7.102c0 .28-.222.509-.501.509h-7.105a.511.511 0 0 1-.51-.509v-7.102zm-63.968 0c0-.283.229-.509.509-.509h29.399c.28 0 .502.226.502.509v7.102c0 .28-.222.509-.502.509H8.912a.51.51 0 0 1-.509-.509v-7.102zm7.863 45.454a.727.727 0 0 1-.727.727H14.28v6.466c0 1-.822 1.821-1.829 1.821-.516 0-.97-.199-1.301-.53a1.829 1.829 0 0 1-.531-1.291v-6.466H9.51a.726.726 0 0 1-.727-.727v-6.854c0-.4.327-.727.727-.727h1.11V37.583c0-1.017.822-1.839 1.832-1.839.505 0 .96.211 1.291.542a1.8 1.8 0 0 1 .538 1.297v19.653h1.259c.4 0 .727.326.727.727v6.854zm11.02-13.204a.73.73 0 0 1-.727.728h-1.11v19.651a1.835 1.835 0 0 1-1.832 1.839c-.506 0-.96-.21-1.291-.541a1.8 1.8 0 0 1-.538-1.298V52.341H20.53a.73.73 0 0 1-.727-.728v-6.855c0-.403.327-.727.727-.727h1.259v-6.466a1.83 1.83 0 0 1 1.829-1.821c.516 0 .97.2 1.301.531.331.331.531.792.531 1.29v6.466h1.11c.4 0 .727.324.727.727v6.855zm11.268 13.204a.727.727 0 0 1-.727.727h-1.259v6.466c0 1-.821 1.821-1.829 1.821-.516 0-.97-.199-1.301-.53a1.828 1.828 0 0 1-.53-1.291v-6.466h-1.11a.726.726 0 0 1-.727-.727v-6.854c0-.4.327-.727.727-.727h1.11V37.583c0-1.017.821-1.839 1.832-1.839.505 0 .959.211 1.291.542a1.8 1.8 0 0 1 .538 1.297v19.653h1.259c.4 0 .727.326.727.727v6.854zm10.94-13.204a.73.73 0 0 1-.728.728h-1.11v19.651a1.835 1.835 0 0 1-1.832 1.839 1.82 1.82 0 0 1-1.29-.541 1.802 1.802 0 0 1-.539-1.298V52.341h-1.259a.73.73 0 0 1-.727-.728v-6.855c0-.403.327-.727.727-.727h1.259v-6.466c0-.999.822-1.821 1.829-1.821.516 0 .97.2 1.301.531.331.331.53.792.53 1.29v6.466h1.11c.4 0 .728.324.728.727v6.855zm8.703-32.25c0-.283.229-.509.508-.509h7.106c.279 0 .501.226.501.509v7.102c0 .28-.222.509-.501.509h-7.106a.51.51 0 0 1-.508-.509v-7.102zm4.176 53.927a4.083 4.083 0 0 1-4.082-4.082c0-2.25 1.828-4.078 4.082-4.078s4.078 1.828 4.078 4.078a4.08 4.08 0 0 1-4.078 4.082zm0-14.709a4.082 4.082 0 1 1 0-8.163 4.078 4.078 0 0 1 4.078 4.081 4.08 4.08 0 0 1-4.078 4.082zm0-14.713a4.082 4.082 0 0 1-4.082-4.081 4.08 4.08 0 0 1 8.16 0 4.079 4.079 0 0 1-4.078 4.081zM76.438 73.29a4.082 4.082 0 0 1-4.081-4.082 4.081 4.081 0 0 1 4.081-4.078 4.078 4.078 0 0 1 4.078 4.078 4.078 4.078 0 0 1-4.078 4.082zm0-14.709a4.081 4.081 0 0 1 0-8.163 4.078 4.078 0 0 1 4.078 4.081 4.08 4.08 0 0 1-4.078 4.082zm0-14.713a4.082 4.082 0 0 1-4.081-4.081 4.08 4.08 0 0 1 8.159 0 4.078 4.078 0 0 1-4.078 4.081z" />
</svg>;
};

View file

@ -11,7 +11,7 @@ import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types";
import { FluxDispatcher } from "@webpack/common";
import { ChatBarIcon } from "./components/Icons";
import { CharBarButton, ChatBarIcon } from "./components/Icons";
import { OpenSBLogsButton } from "./components/SoundBoardLog";
import settings from "./settings";
import { updateLoggedSounds } from "./store";
@ -56,7 +56,7 @@ export default definePlugin({
await updateLoggedSounds(sound);
getListeners().forEach(cb => cb());
});
if (settings.store.IconLocation === "chat") addChatBarButton("vc-soundlog-button", ChatBarIcon);
if (settings.store.IconLocation === "chat") addChatBarButton("vc-soundlog-button", CharBarButton, ChatBarIcon);
},
stop() {
disableStyle(styles);

View file

@ -52,17 +52,18 @@ export default definePlugin({
contextMenus: {
"message": messageCtxPatch
},
renderMessageAccessory: props => <Accessory message={props.message} />,
renderMessagePopoverButton: message => {
if (!message.content) return null;
return {
label: "Translate",
icon: Icon,
message: message,
channel: ChannelStore.getChannel(message.channel_id),
onClick: () => handleTranslate(message),
};
},
messagePopoverButton: {
icon: Icon,
render(message) {
if (!message.content) return null;
return {
label: "Translate",
icon: Icon,
message: message,
channel: ChannelStore.getChannel(message.channel_id),
onClick: () => handleTranslate(message),
};
}
}
});

View file

@ -4,11 +4,11 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { cl, IconProps } from "@equicordplugins/translatePlus/misc/types";
import { cl } from "@equicordplugins/translatePlus/misc/types";
export function Icon({ width = 24, height = 24 }: IconProps) {
export function Icon() {
return (
<svg viewBox="0 96 960 960" height={width} width={height} className={cl("icon")}>
<svg viewBox="0 96 960 960" height={24} width={24} className={cl("icon")}>
<path fill="currentColor" d="m475 976 181-480h82l186 480h-87l-41-126H604l-47 126h-82Zm151-196h142l-70-194h-2l-70 194Zm-466 76-55-55 204-204q-38-44-67.5-88.5T190 416h87q17 33 37.5 62.5T361 539q45-47 75-97.5T487 336H40v-80h280v-80h80v80h280v80H567q-22 69-58.5 135.5T419 598l98 99-30 81-127-122-200 200Z" />
<path fill="currentColor" d="m 830.17456,136.43701 c -11.54729,0 -20.84473,8.71252 -20.84473,19.53369 v 66.21826 h -66.21826 c -10.82122,0 -19.53369,9.29373 -19.53369,20.84107 0,11.54734 8.71247,20.84473 19.53369,20.84473 h 66.21826 v 66.21826 c 0,10.8212 9.29742,19.53369 20.84473,19.53369 11.54731,0 20.84106,-8.71249 20.84106,-19.53369 v -66.21826 h 66.21827 c 10.82124,0 19.53369,-9.29737 19.53369,-20.84473 0,-11.54736 -8.71245,-20.84107 -19.53369,-20.84107 H 851.01562 V 155.9707 c 0,-10.82117 -9.29377,-19.53369 -20.84106,-19.53369 z" />
<rect fill="currentColor" width="0.42110577" height="2.1055288" x="848.52814" y="112.42313" ry="0.2105529" />

View file

@ -20,7 +20,7 @@ import { classNameFactory } from "@api/Styles";
import { Message } from "@vencord/discord-types";
import { useState } from "@webpack/common";
export const conversions = new Map<string,(conv: string) => void>();
export const conversions = new Map<string, (conv: string) => void>();
const cl = classNameFactory("vc-converter-");
function Dismiss({ onDismiss }: { onDismiss: () => void; }) {
return (
@ -33,17 +33,13 @@ function Dismiss({ onDismiss }: { onDismiss: () => void; }) {
);
}
// thanks <@408047304864432139>
export function ConvertIcon({ height = 24, width = 24, className }: {
height?: number,
width?: number,
className?: string;
}) {
export function ConvertIcon() {
return (
<svg
viewBox="0 0 98 98"
height={height}
width={width}
className={[cl("icon"), className].join(" ")}
height={24}
width={24}
className={cl("icon")}
>
<path
fill="currentColor"
@ -51,13 +47,29 @@ export function ConvertIcon({ height = 24, width = 24, className }: {
</svg>
);
}
export function SmallConvertIcon() {
return (
<svg
viewBox="0 0 98 98"
height={16}
width={16}
className={cl("icon")}
>
<path
fill="currentColor"
d="m50 16.668v-7.4609c0-1.875-2.25-2.7891-3.543-1.457l-11.664 11.625c-0.83594 0.83203-0.83594 2.125 0 2.957l11.625 11.625c1.332 1.293 3.582 0.375 3.582-1.5v-7.457c13.793 0 25 11.207 25 25 0 3.293-0.625 6.5-1.832 9.375-0.625 1.5-0.16797 3.207 0.95703 4.332 2.125 2.125 5.707 1.375 6.832-1.4141 1.543-3.793 2.375-7.9609 2.375-12.293 0-18.418-14.914-33.332-33.332-33.332zm0 58.332c-13.793 0-25-11.207-25-25 0-3.293 0.625-6.5 1.832-9.375 0.625-1.5 0.16797-3.207-0.95703-4.332-2.125-2.125-5.707-1.375-6.832 1.4141-1.543 3.793-2.375 7.9609-2.375 12.293 0 18.418 14.914 33.332 33.332 33.332v7.4609c0 1.875 2.25 2.7891 3.543 1.457l11.625-11.625c0.83203-0.83203 0.83203-2.125 0-2.957l-11.625-11.625c-1.293-1.293-3.543-0.375-3.543 1.5z" />
</svg>
);
}
export function ConverterAccessory({ message }: { message: Message; }) {
const [conversion, setConversion] = useState<string>("");
conversions.set(message.id, setConversion);
if (!conversion) return null;
return (
<span className={cl("accessory")}>
<ConvertIcon width={16} height={16} />
<SmallConvertIcon />
{conversion}
{" - "}
<Dismiss onDismiss={() => setConversion("")} />

View file

@ -19,7 +19,6 @@
import "./style.css";
import { addMessageAccessory } from "@api/MessageAccessories";
import { addMessagePopoverButton } from "@api/MessagePopover";
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
@ -50,9 +49,9 @@ export default definePlugin({
name: "UnitConverter",
description: "Converts metric units to Imperal units and vice versa",
authors: [Devs.sadan],
start() {
addMessageAccessory("vc-converter", props => <ConverterAccessory message={props.message} />);
addMessagePopoverButton("vc-converter", message => {
messagePopoverButton: {
icon: ConvertIcon,
render(message) {
if (!message.content) return null;
return {
label: "Convert Units",
@ -65,7 +64,10 @@ export default definePlugin({
setConversion(convert(message.content));
}
};
});
}
},
start() {
addMessageAccessory("vc-converter", props => <ConverterAccessory message={props.message} />);
},
settings,
});