mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 15:35:11 +00:00
HideAttachments Refactor to use Styles API
This commit is contained in:
parent
b029ce47a0
commit
55090b76cd
1 changed files with 19 additions and 16 deletions
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
import { get, set } from "@api/DataStore";
|
import { get, set } from "@api/DataStore";
|
||||||
import { addButton, removeButton } from "@api/MessagePopover";
|
import { addButton, removeButton } from "@api/MessagePopover";
|
||||||
|
import { setStyle } from "@api/Styles";
|
||||||
import { ImageInvisible, ImageVisible } from "@components/Icons";
|
import { ImageInvisible, ImageVisible } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
@ -41,10 +42,6 @@ export default definePlugin({
|
||||||
dependencies: ["MessagePopoverAPI"],
|
dependencies: ["MessagePopoverAPI"],
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
style = document.createElement("style");
|
|
||||||
style.id = "VencordHideAttachments";
|
|
||||||
document.head.appendChild(style);
|
|
||||||
|
|
||||||
await getHiddenMessages();
|
await getHiddenMessages();
|
||||||
await this.buildCss();
|
await this.buildCss();
|
||||||
|
|
||||||
|
@ -64,24 +61,30 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
style.remove();
|
setStyle({
|
||||||
|
name: "HideAttachments",
|
||||||
|
enabled: false
|
||||||
|
});
|
||||||
hiddenMessages.clear();
|
hiddenMessages.clear();
|
||||||
removeButton("HideAttachments");
|
removeButton("HideAttachments");
|
||||||
},
|
},
|
||||||
|
|
||||||
async buildCss() {
|
async buildCss() {
|
||||||
const elements = [...hiddenMessages].map(id => `#message-accessories-${id}`).join(",");
|
const elements = [...hiddenMessages].map(id => `#message-accessories-${id}`).join(",");
|
||||||
style.textContent = `
|
setStyle({
|
||||||
:is(${elements}) :is([class*="embedWrapper"], [class*="clickableSticker"]) {
|
name: "HideAttachments",
|
||||||
/* important is not necessary, but add it to make sure bad themes won't break it */
|
source: `
|
||||||
display: none !important;
|
:is(${elements}) :is([class*="embedWrapper"], [class*="clickableSticker"]) {
|
||||||
}
|
/* important is not necessary, but add it to make sure bad themes won't break it */
|
||||||
:is(${elements})::after {
|
display: none !important;
|
||||||
content: "Attachments hidden";
|
}
|
||||||
color: var(--text-muted);
|
:is(${elements})::after {
|
||||||
font-size: 80%;
|
content: "Attachments hidden";
|
||||||
}
|
color: var(--text-muted);
|
||||||
`;
|
font-size: 80%;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async toggleHide(id: string) {
|
async toggleHide(id: string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue