oop
This commit is contained in:
parent
a9fee6248e
commit
3e9672c6b8
1 changed files with 18 additions and 15 deletions
|
@ -20,6 +20,20 @@ import { Settings } from "../api/settings";
|
||||||
import { Devs } from "../utils/constants";
|
import { Devs } from "../utils/constants";
|
||||||
import definePlugin, { OptionType } from "../utils/types";
|
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({
|
export default definePlugin({
|
||||||
name: "BlurNSFW",
|
name: "BlurNSFW",
|
||||||
description: "Blur attachments in NSFW channels until hovered",
|
description: "Blur attachments in NSFW channels until hovered",
|
||||||
|
@ -43,30 +57,19 @@ export default definePlugin({
|
||||||
type: OptionType.NUMBER,
|
type: OptionType.NUMBER,
|
||||||
description: "Blur Amount",
|
description: "Blur Amount",
|
||||||
default: 10,
|
default: 10,
|
||||||
|
onChange: setCss
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
const style = this.style = document.createElement("style");
|
style = document.createElement("style");
|
||||||
style.id = "VcBlurNsfw";
|
style.id = "VcBlurNsfw";
|
||||||
document.head.appendChild(style);
|
document.head.appendChild(style);
|
||||||
|
|
||||||
this.setCss();
|
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;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
this.style?.remove();
|
style?.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue