Plugin

BlurNSFW

Blur attachments in NSFW channels until hovered

Privacy Appearance
index.ts
Download

Source

src/plugins/blurNsfw/index.ts
1/*
2 * FiveCord — a Discord client mod
3 * Copyright (c) 2025 FiveCord
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7import { definePluginSettings } from "@api/Settings";
8import { managedStyleRootNode } from "@api/Styles";
9import { Devs } from "@utils/constants";
10import { createAndAppendStyle } from "@utils/css";
11import definePlugin, { OptionType } from "@utils/types";
12
13let style: HTMLStyleElement;
14
15const settings = definePluginSettings({
16 blurAmount: {
17 type: OptionType.NUMBER,
18 description: "Blur Amount (in pixels)",
19 default: 10,
20 onChange: setCss
21 }
22});
23
24function setCss() {
25 style.textContent = `
26 .vc-nsfw-img [class*=imageContainer],
27 .vc-nsfw-img [class*=wrapperPaused] {
28 filter: blur(${settings.store.blurAmount}px);
29 transition: filter 0.2s;
30
31 &:hover {
32 filter: blur(0);
33 }
34 }
35 `;
36}
37
38export default definePlugin({
39 name: "BlurNSFW",
40 description: "Blur attachments in NSFW channels until hovered",
41 tags: ["Privacy", "Appearance"],
42 authors: [Devs.Ven],
43 settings,
44
45 patches: [
46 {
47 find: "}renderStickersAccessories(",
48 replacement: [
49 {
50 match: /(\.renderReactions\(\i\).+?className:)/,
51 replace: '$&(this?.props?.channel?.nsfw?"vc-nsfw-img ":"")+'
52 }
53 ]
54 }
55 ],
56
57 start() {
58 style = createAndAppendStyle("VcBlurNsfw", managedStyleRootNode);
59
60 setCss();
61 },
62
63 stop() {
64 style?.remove();
65 }
66});
67