aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-11-28 00:58:26 +0100
committerVendicated <vendicated@riseup.net>2022-11-28 00:58:26 +0100
commit3e9672c6b8e8cb78cbc571ba2161513e95a61226 (patch)
treef3c441be351cd27547ca54c952a379b7c67262f8
parenta9fee6248eb99a12abfa0fc9e5040feb7f5c676f (diff)
downloadVencord-3e9672c6b8e8cb78cbc571ba2161513e95a61226.tar.gz
Vencord-3e9672c6b8e8cb78cbc571ba2161513e95a61226.tar.bz2
Vencord-3e9672c6b8e8cb78cbc571ba2161513e95a61226.zip
oop
-rw-r--r--src/plugins/blurNsfw.ts33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/plugins/blurNsfw.ts b/src/plugins/blurNsfw.ts
index d04e497..de4eb0c 100644
--- a/src/plugins/blurNsfw.ts
+++ b/src/plugins/blurNsfw.ts
@@ -20,6 +20,20 @@ import { Settings } from "../api/settings";
import { Devs } from "../utils/constants";
import definePlugin, { OptionType } from "../utils/types";
+let style: HTMLStyleElement;
+
+function setCss() {
+ style.textContent = `
+ .vc-nsfw-img [class^=imageWrapper] img {
+ filter: blur(${Settings.plugins.BlurNSFW.blurAmount}px);
+ transition: filter 0.2s;
+ }
+ .vc-nsfw-img [class^=imageWrapper]:hover img {
+ filter: unset;
+ }
+ `;
+}
+
export default definePlugin({
name: "BlurNSFW",
description: "Blur attachments in NSFW channels until hovered",
@@ -43,30 +57,19 @@ export default definePlugin({
type: OptionType.NUMBER,
description: "Blur Amount",
default: 10,
+ onChange: setCss
}
},
start() {
- const style = this.style = document.createElement("style");
+ style = document.createElement("style");
style.id = "VcBlurNsfw";
document.head.appendChild(style);
- this.setCss();
- },
-
- setCss() {
- this.style.textContent = `
- .vc-nsfw-img [class^=imageWrapper] img {
- filter: blur(${Settings.plugins.BlurNSFW.blurAmount}px);
- transition: filter 0.2s;
- }
- .vc-nsfw-img [class^=imageWrapper] img:hover {
- filter: unset;
- }
- `;
+ setCss();
},
stop() {
- this.style?.remove();
+ style?.remove();
}
});