mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-28 02:06:23 +00:00
ugh
This commit is contained in:
parent
9ce9b1fcb9
commit
5b81994317
1 changed files with 17 additions and 16 deletions
|
@ -6,13 +6,13 @@
|
||||||
|
|
||||||
import { addButton, removeButton } from "@api/MessagePopover";
|
import { addButton, removeButton } from "@api/MessagePopover";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { ChannelStore } from "@webpack/common";
|
import { ChannelStore } from "@webpack/common";
|
||||||
import { get, set } from "@api/DataStore";
|
import { get, set } from "@api/DataStore";
|
||||||
|
|
||||||
let style: HTMLStyleElement;
|
let style: HTMLStyleElement;
|
||||||
|
|
||||||
const KEY = "HideMessage_HiddenIds";
|
const KEY = "HideMessage___HiddenMessages";
|
||||||
|
|
||||||
let hiddenMessages: Set<string> = new Set();
|
let hiddenMessages: Set<string> = new Set();
|
||||||
const getHiddenMessages = () => get(KEY).then(set => {
|
const getHiddenMessages = () => get(KEY).then(set => {
|
||||||
|
@ -31,7 +31,7 @@ const HideIcon = () => {
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "HideMessage",
|
name: "HideMessage",
|
||||||
description: "Adds an option to hide messages",
|
description: "Adds an option to hide messages",
|
||||||
authors: [Devs.IsaacZSH],
|
authors: [Devs.Isaac],
|
||||||
dependencies: ["MessagePopoverAPI"],
|
dependencies: ["MessagePopoverAPI"],
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
|
@ -43,11 +43,6 @@ export default definePlugin({
|
||||||
await this.buildCss();
|
await this.buildCss();
|
||||||
|
|
||||||
addButton("HideMessage", msg => {
|
addButton("HideMessage", msg => {
|
||||||
const handleClick = () => {
|
|
||||||
this.toggleHide(msg.id)
|
|
||||||
console.log(msg)
|
|
||||||
};
|
|
||||||
|
|
||||||
const label = "Hide Message";
|
const label = "Hide Message";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -55,7 +50,7 @@ export default definePlugin({
|
||||||
icon: HideIcon,
|
icon: HideIcon,
|
||||||
message: msg,
|
message: msg,
|
||||||
channel: ChannelStore.getChannel(msg.channel_id),
|
channel: ChannelStore.getChannel(msg.channel_id),
|
||||||
onClick: handleClick,
|
onClick: () => this.toggleHide(`{"channelId": "${msg.channel_id}", "messageId": "${msg.id}"}`)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -65,20 +60,26 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
async buildCss() {
|
async buildCss() {
|
||||||
console.log(hiddenMessages)
|
let chatMessages = ""
|
||||||
console.log(...hiddenMessages)
|
let messagesContent = ""
|
||||||
const elements = [...hiddenMessages].map(id => `#message-content-${id}`).join(",");
|
hiddenMessages.forEach((ids) => {
|
||||||
|
chatMessages += `#chat-messages-${JSON.parse(ids).channelId}-${JSON.parse(ids).messageId},`
|
||||||
|
messagesContent += `#message-content-${JSON.parse(ids).messageId},`
|
||||||
|
})
|
||||||
style.textContent = `
|
style.textContent = `
|
||||||
:is(${elements}) {
|
:is(${chatMessages}) :is([class*="message_d5deea"]) :is([class*="embedWrapper"], [class*="clickableSticker"]) {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
:is(${messagesContent}) {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
},
|
},
|
||||||
|
|
||||||
async toggleHide(id: string) {
|
async toggleHide(sentIds: string) {
|
||||||
const ids = await getHiddenMessages();
|
const ids = await getHiddenMessages();
|
||||||
if (!ids.delete(id))
|
if (!ids.delete(sentIds))
|
||||||
ids.add(id);
|
ids.add(sentIds);
|
||||||
|
|
||||||
await saveHiddenMessages(ids);
|
await saveHiddenMessages(ids);
|
||||||
await this.buildCss();
|
await this.buildCss();
|
||||||
|
|
Loading…
Reference in a new issue