mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-20 03:47:01 -04:00
Improvements for patches and misc stuff (#582)
This commit is contained in:
parent
7322c3af04
commit
40395d562a
15 changed files with 324 additions and 282 deletions
|
@ -21,7 +21,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
|||
import { Devs } from "@utils/constants";
|
||||
import { useForceUpdater } from "@utils/misc";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
||||
import { Tooltip } from "webpack/common";
|
||||
|
||||
enum ActivitiesTypes {
|
||||
|
@ -37,7 +37,7 @@ interface IgnoredActivity {
|
|||
const RegisteredGamesClasses = findByPropsLazy("overlayToggleIconOff", "overlayToggleIconOn");
|
||||
const TryItOutClasses = findByPropsLazy("tryItOutBadge", "tryItOutBadgeIcon");
|
||||
const BaseShapeRoundClasses = findByPropsLazy("baseShapeRound", "baseShapeRoundLeft", "baseShapeRoundRight");
|
||||
const RunningGameStore = findByPropsLazy("getRunningGames", "getGamesSeen");
|
||||
const RunningGameStore = findStoreLazy("RunningGameStore");
|
||||
|
||||
function ToggleIconOff() {
|
||||
return (
|
||||
|
@ -71,7 +71,7 @@ function ToggleIconOff() {
|
|||
);
|
||||
}
|
||||
|
||||
function ToggleIconOn() {
|
||||
function ToggleIconOn({ forceWhite }: { forceWhite?: boolean; }) {
|
||||
return (
|
||||
<svg
|
||||
className={RegisteredGamesClasses.overlayToggleIconOn}
|
||||
|
@ -80,14 +80,15 @@ function ToggleIconOn() {
|
|||
viewBox="0 0 32 26"
|
||||
>
|
||||
<path
|
||||
className={RegisteredGamesClasses.fill}
|
||||
className={forceWhite ? "" : RegisteredGamesClasses.fill}
|
||||
fill={forceWhite ? "var(--white-500)" : ""}
|
||||
d="M 16 8 C 7.664063 8 1.25 15.34375 1.25 15.34375 L 0.65625 16 L 1.25 16.65625 C 1.25 16.65625 7.097656 23.324219 14.875 23.9375 C 15.246094 23.984375 15.617188 24 16 24 C 16.382813 24 16.753906 23.984375 17.125 23.9375 C 24.902344 23.324219 30.75 16.65625 30.75 16.65625 L 31.34375 16 L 30.75 15.34375 C 30.75 15.34375 24.335938 8 16 8 Z M 16 10 C 18.203125 10 20.234375 10.601563 22 11.40625 C 22.636719 12.460938 23 13.675781 23 15 C 23 18.613281 20.289063 21.582031 16.78125 21.96875 C 16.761719 21.972656 16.738281 21.964844 16.71875 21.96875 C 16.480469 21.980469 16.242188 22 16 22 C 15.734375 22 15.476563 21.984375 15.21875 21.96875 C 11.710938 21.582031 9 18.613281 9 15 C 9 13.695313 9.351563 12.480469 9.96875 11.4375 L 9.9375 11.4375 C 11.71875 10.617188 13.773438 10 16 10 Z M 16 12 C 14.34375 12 13 13.34375 13 15 C 13 16.65625 14.34375 18 16 18 C 17.65625 18 19 16.65625 19 15 C 19 13.34375 17.65625 12 16 12 Z M 7.25 12.9375 C 7.09375 13.609375 7 14.285156 7 15 C 7 16.753906 7.5 18.394531 8.375 19.78125 C 5.855469 18.324219 4.105469 16.585938 3.53125 16 C 4.011719 15.507813 5.351563 14.203125 7.25 12.9375 Z M 24.75 12.9375 C 26.648438 14.203125 27.988281 15.507813 28.46875 16 C 27.894531 16.585938 26.144531 18.324219 23.625 19.78125 C 24.5 18.394531 25 16.753906 25 15 C 25 14.285156 24.90625 13.601563 24.75 12.9375 Z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
function ToggleActivityComponent({ activity }: { activity: IgnoredActivity; }) {
|
||||
function ToggleActivityComponent({ activity, forceWhite }: { activity: IgnoredActivity; forceWhite?: boolean; }) {
|
||||
const forceUpdate = useForceUpdater();
|
||||
|
||||
return (
|
||||
|
@ -105,7 +106,7 @@ function ToggleActivityComponent({ activity }: { activity: IgnoredActivity; }) {
|
|||
{
|
||||
ignoredActivitiesCache.has(activity.id)
|
||||
? <ToggleIconOff />
|
||||
: <ToggleIconOn />
|
||||
: <ToggleIconOn forceWhite={forceWhite} />
|
||||
}
|
||||
</div>
|
||||
)}
|
||||
|
@ -117,9 +118,9 @@ function ToggleActivityComponentWithBackground({ activity }: { activity: Ignored
|
|||
return (
|
||||
<div
|
||||
className={`${TryItOutClasses.tryItOutBadge} ${BaseShapeRoundClasses.baseShapeRound}`}
|
||||
style={{ padding: "0 2px" }}
|
||||
style={{ padding: "0px 2px" }}
|
||||
>
|
||||
<ToggleActivityComponent activity={activity} />
|
||||
<ToggleActivityComponent activity={activity} forceWhite={true} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -142,28 +143,32 @@ export default definePlugin({
|
|||
name: "IgnoreActivities",
|
||||
authors: [Devs.Nuckyz],
|
||||
description: "Ignore certain activities (like games and actual activities) from showing up on your status. You can configure which ones are ignored from the Registered Games and Activities tabs.",
|
||||
patches: [{
|
||||
find: ".Messages.SETTINGS_GAMES_TOGGLE_OVERLAY",
|
||||
replacement: {
|
||||
match: /!(\i)\|\|(null==\i\)return null;var \i=(\i)\.overlay.+?children:)(\[.{0,70}overlayStatusText.+?\])(?=}\)}\(\))/,
|
||||
replace: (_, platformCheck, restWithoutPlatformCheck, props, children) => ""
|
||||
+ `${restWithoutPlatformCheck}`
|
||||
+ `(${platformCheck}?${children}:[])`
|
||||
+ `.concat(Vencord.Plugins.plugins.IgnoreActivities.renderToggleGameActivityButton(${props}))`
|
||||
patches: [
|
||||
{
|
||||
find: ".Messages.SETTINGS_GAMES_TOGGLE_OVERLAY",
|
||||
replacement: {
|
||||
match: /!(\i)\|\|(null==\i\)return null;var \i=(\i)\.overlay.+?children:)(\[.{0,70}overlayStatusText.+?\])(?=}\)}\(\))/,
|
||||
replace: (_, platformCheck, restWithoutPlatformCheck, props, children) => ""
|
||||
+ `${restWithoutPlatformCheck}`
|
||||
+ `(${platformCheck}?${children}:[])`
|
||||
+ `.concat(Vencord.Plugins.plugins.IgnoreActivities.renderToggleGameActivityButton(${props}))`
|
||||
}
|
||||
},
|
||||
{
|
||||
find: ".overlayBadge",
|
||||
replacement: {
|
||||
match: /(?<=\(\)\.badgeContainer.+?(\i)\.name}\):null)/,
|
||||
replace: (_, props) => `,$self.renderToggleActivityButton(${props})`
|
||||
}
|
||||
},
|
||||
{
|
||||
find: '.displayName="LocalActivityStore"',
|
||||
replacement: {
|
||||
match: /LISTENING.+?\)\);(?<=(\i)\.push.+?)/,
|
||||
replace: (m, activities) => `${m}${activities}=${activities}.filter($self.isActivityNotIgnored);`
|
||||
}
|
||||
}
|
||||
}, {
|
||||
find: ".overlayBadge",
|
||||
replacement: {
|
||||
match: /.badgeContainer.+?.\?\(0,.\.jsx\)\(.{1,2},{name:(?<props>.)\.name}\):null/,
|
||||
replace: "$&,$self.renderToggleActivityButton($<props>)"
|
||||
}
|
||||
}, {
|
||||
find: '.displayName="LocalActivityStore"',
|
||||
replacement: {
|
||||
match: /(?<activities>.)\.push\(.\({type:.\..{1,3}\.LISTENING.+?\)\)/,
|
||||
replace: "$&;$<activities>=$<activities>.filter($self.isActivityNotIgnored);"
|
||||
}
|
||||
}],
|
||||
],
|
||||
|
||||
async start() {
|
||||
const ignoredActivitiesData = await DataStore.get<string[] | Map<IgnoredActivity["id"], IgnoredActivity>>("IgnoreActivities_ignoredActivities") ?? new Map<IgnoredActivity["id"], IgnoredActivity>();
|
||||
|
@ -217,5 +222,5 @@ export default definePlugin({
|
|||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue