Restrict DisableAnimations

This commit is contained in:
thororen1234 2024-12-18 22:08:42 -05:00
parent 9bcc47afa2
commit e2ca547b2e
3 changed files with 42 additions and 20 deletions

View file

@ -19,35 +19,45 @@
import { EquicordDevs } from "@utils/constants"; import { EquicordDevs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { findAll } from "@webpack"; import { findAll } from "@webpack";
import { Forms } from "@webpack/common";
export default definePlugin({ export default definePlugin({
name: "DisableAnimations", name: "DisableAnimations",
description: "Disables most of Discord's animations.", description: "Disables most of Discord's animations.",
authors: [EquicordDevs.seth], authors: [EquicordDevs.seth],
settingsAboutComponent: () => <>
<Forms.FormText className="platform-warning">
This plugin will only work on Equibop Vesktop and Discord Desktop
</Forms.FormText>
</>,
start() { start() {
this.springs = findAll((mod) => { if (IS_EQUIBOP || IS_VESKTOP || IS_DISCORD_DESKTOP) {
if (!mod.Globals) return false; this.springs = findAll(mod => {
return true; if (!mod.Globals) return false;
}); return true;
for (const spring of this.springs) {
spring.Globals.assign({
skipAnimation: true,
}); });
for (const spring of this.springs) {
spring.Globals.assign({
skipAnimation: true,
});
}
this.css = document.createElement("style");
this.css.innerText = "* { transition: none !important; animation: none !important; }";
document.head.appendChild(this.css);
} }
this.css = document.createElement("style");
this.css.innerText = "* { transition: none !important; animation: none !important; }";
document.head.appendChild(this.css);
}, },
stop() { stop() {
for (const spring of this.springs) { if (IS_EQUIBOP || IS_VESKTOP || IS_DISCORD_DESKTOP) {
spring.Globals.assign({ for (const spring of this.springs) {
skipAnimation: false, spring.Globals.assign({
}); skipAnimation: false,
} });
}
if (this.css) this.css.remove(); if (this.css) this.css.remove();
}
} }
}); });

View file

@ -0,0 +1,12 @@
.platform-warning {
font-size: 16px !important;
background-color: rgb(240 71 71 / 10%);
color: rgb(240 71 71) !important;
border: 1px solid rgb(240 71 71 / 60%) !important;
border-radius: 5px !important;
font-weight: 500;
padding: 6px 10px;
text-align: center;
margin-top: 10px;
font-style: bold;
}

View file

@ -28,7 +28,7 @@ export default definePlugin({
authors: [EquicordDevs.vappstar], authors: [EquicordDevs.vappstar],
settingsAboutComponent: () => <> settingsAboutComponent: () => <>
<Forms.FormText className="platform-warning"> <Forms.FormText className="platform-warning">
This plugin will cause discord to use more resources than normal. This plugin will cause discord to use more resources than normal
</Forms.FormText> </Forms.FormText>
</>, </>,
patches: [ patches: [