Skip to content

Commit 50f9a47

Browse files
committed
fix: plaintext patches and other module matches
1 parent 46af528 commit 50f9a47

File tree

13 files changed

+36
-42
lines changed

13 files changed

+36
-42
lines changed

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"replug",
5757
"replugged",
5858
"scroller",
59+
"setsize",
5960
"signingkey",
6061
"Skema",
6162
"skus",

src/renderer/coremods/badges/plaintextPatches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default [
77
replacements: [
88
// Add the "replugged-badge" class if it's our custom badge
99
{
10-
match: /src:null!=\(\i=(\i)\.iconSrc\).{15,30}?,className:\i\(\)\(\i\.badge,\i/,
10+
match: /src:null!=\(\i=(\i)\.iconSrc\).{15,30}?,className:\i\(\)\(\i\.\i,\i/,
1111
replace: `$&,{["replugged-badge"]:$1.component}`,
1212
},
1313
// Change to a div and add a children for our custom badge

src/renderer/coremods/commands/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async function injectRepluggedSectionIcon(): Promise<void> {
9292

9393
async function injectApplicationCommandIndexStore(): Promise<void> {
9494
const applicationCommandIndexStoreMod = await waitForModule<Record<string, UseDiscoveryState>>(
95-
filters.bySource("APPLICATION_COMMAND_INDEX"),
95+
filters.bySource(".APPLICATION_COMMAND_CACHE_FETCH,"),
9696
);
9797
const useDiscoveryStateKey = getFunctionKeyBySource(
9898
applicationCommandIndexStoreMod,

src/renderer/coremods/experiments/plaintextPatches.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ export default (generalSettings.get("experiments")
4949
: []),
5050
// Always return true for the 'isStaff' property in SettingRendererUtils
5151
alwaysTruePatch(`header:"Developer Only"`, /isStaff:\i/),
52-
// Add developer only settings to the UserSettingsCogContextMenu
53-
alwaysTruePatch(`layoutDebuggingEnabled,isStaff:`, "isStaff())===!0"),
5452
// Show the Playgrounds and Build Overrides menu items in the UserSettingsCogContextMenu
5553
alwaysTruePatch("user-settings-cog", /isStaff\(\)/g),
5654
// Show the ExperimentEmbed
57-
alwaysTruePatch(/className:\i\.experimentOverride,/, ".isStaffPersonal())"),
55+
alwaysTruePatch('"Clear Treatment ".concat(', ".isStaffPersonal())"),
5856
// Show the PlaygroundEmbed
5957
alwaysTruePatch("data-has-story", ".isStaffPersonal())"),
6058
// Show the Playgrounds tab in the UserSettingsCogContextMenu

src/renderer/coremods/installer/AddonEmbed.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { React, classNames } from "@common";
22
import { t as discordT, intl } from "@common/i18n";
33
import { Button, Clickable, Text, Tooltip } from "@components";
44
import { Logger } from "@replugged";
5-
import { getByProps } from "@webpack";
5+
import { getBySource } from "@webpack";
66
import { t } from "src/renderer/modules/i18n";
7-
import { openExternal } from "src/renderer/util";
7+
import { mapClassNames, openExternal } from "src/renderer/util";
88
import type { CheckResultSuccess } from "src/types";
99
import { getSourceLink } from "../settings/pages";
1010
import { type InstallLinkProps, authorList, checkIsInstalled, getInfo, install } from "./util";
@@ -61,12 +61,13 @@ function Link({ className }: { className?: string }): React.ReactElement {
6161
}
6262

6363
const Icon = React.memo(({ className }: { className?: string }): React.ReactElement | null => {
64-
const svgMod = getByProps<SvgMod>("svgContentRight");
64+
const svgMod = getBySource<SvgMod>("svgContentRight_");
6565
if (!svgMod) {
6666
logger.error("Failed to get svgMod");
6767
return null;
6868
}
69-
const { svgContentRight, svgContentLines, svgContentLeft, svgDots, svgTag } = svgMod;
69+
const { svgContentRight, svgContentLines, svgContentLeft, svgDots, svgTag } =
70+
mapClassNames(svgMod);
7071

7172
return (
7273
<svg width="57" height="40" viewBox="0 0 57 40" fill="none" className={className}>
@@ -119,7 +120,7 @@ const Embed = React.memo(
119120
installClick: () => void;
120121
},
121122
): React.ReactElement | null => {
122-
const classMod = getByProps<ClassMod>("titleRegion");
123+
const classMod = getBySource<ClassMod>("titleRegion_");
123124
if (!classMod) {
124125
logger.error("Failed to find classMod");
125126
return null;
@@ -142,7 +143,7 @@ const Embed = React.memo(
142143
copyLink,
143144
copyLinkIcon,
144145
copied,
145-
} = classMod;
146+
} = mapClassNames(classMod);
146147

147148
return (
148149
<div className={wrapper}>

src/renderer/coremods/language/index.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { intl } from "@common/i18n";
2-
import { Flex, Text } from "@components";
32
import { messagesLoader } from "i18n/en-US.messages";
43
import type React from "react";
54
import { t } from "../../modules/i18n";
@@ -11,22 +10,6 @@ export function getFormattedPercentage(locale: string): React.ReactNode {
1110
return intl.format(t.REPLUGGED_I18N_TRANSLATED_PERCENTAGE, { translated: Number(percentage) });
1211
}
1312

14-
export function _renderLabel({
15-
label,
16-
value,
17-
}: {
18-
label: string;
19-
localizedName: string;
20-
value: string;
21-
}): React.ReactElement {
22-
return (
23-
<Flex direction={Flex.Direction.VERTICAL}>
24-
<Text variant="text-md/normal">{label}</Text>
25-
<Text variant="text-xs/normal">{getFormattedPercentage(value)}</Text>
26-
</Flex>
27-
);
28-
}
29-
3013
export function start(): void {
3114
const totalStrCount = Object.keys(messagesLoader.messages[messagesLoader.defaultLocale]).length;
3215

src/renderer/coremods/language/plaintextPatches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default [
66
replacements: [
77
{
88
match: /value:(\i),options/,
9-
replace: `renderOptionLabel:$exports?._renderLabel,helperText:$exports?.getFormattedPercentage($1),$&`,
9+
replace: `helperText:$exports?.getFormattedPercentage($1),$&`,
1010
},
1111
],
1212
},

src/renderer/coremods/messagePopover/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export function _buildPopoverElements(msg: Message, channel: Channel): React.Rea
4242
const items: React.ReactElement[] = [];
4343

4444
// Waiting for the module is not necessary, as it is already loaded by the time this function is called
45-
const hoverBarButtonStr = ".hoverBarButton";
46-
const hoverBarMod = getBySource<Record<string, HoverBarButton>>(hoverBarButtonStr)!;
47-
const HoverBarButton = getComponentBySource<HoverBarButton>(hoverBarMod, hoverBarButtonStr);
45+
const hoverBarButtonRegex = /disabled:\i,dangerous:\i/;
46+
const hoverBarMod = getBySource<Record<string, HoverBarButton>>(hoverBarButtonRegex)!;
47+
const HoverBarButton = getComponentBySource<HoverBarButton>(hoverBarMod, hoverBarButtonRegex);
4848

4949
if (!HoverBarButton) {
5050
logger.error("Could not find HoverBarButton");

src/renderer/coremods/notices/noticeMod.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ interface NoticeMod {
1313
}
1414

1515
const actualNoticeMod = await waitForModule<Record<string, ValueOf<NoticeMod>>>(
16-
filters.bySource(".colorPremiumTier1,"),
16+
filters.bySource(/PREMIUM_TIER_1:\i\.\i,/),
1717
);
1818

1919
const remappedNoticeMod: NoticeMod = {
2020
NoticeColors: Object.values(actualNoticeMod).find((v) => typeof v === "object")!,
21-
NoticeButton: getFunctionBySource(actualNoticeMod, "buttonMinor")!,
22-
PrimaryCTANoticeButton: getFunctionBySource(actualNoticeMod, "additionalTrackingProps")!,
23-
NoticeButtonAnchor: getFunctionBySource(actualNoticeMod, ".button,href:")!,
24-
NoticeCloseButton: getFunctionBySource(actualNoticeMod, "closeIcon")!,
25-
Notice: getFunctionBySource(actualNoticeMod, "isMobile")!,
21+
NoticeButton: getFunctionBySource(actualNoticeMod, /minor:\i=!1/)!,
22+
PrimaryCTANoticeButton: getFunctionBySource(actualNoticeMod, /\.onClick&&\i\.onClick/)!,
23+
NoticeButtonAnchor: getFunctionBySource(actualNoticeMod, /href:\i,onClick/)!,
24+
NoticeCloseButton: getFunctionBySource(actualNoticeMod, "focusProps:{offset:")!,
25+
Notice: getFunctionBySource(actualNoticeMod, /color:\i=\i\.DEFAULT/)!,
2626
};
2727

2828
export default remappedNoticeMod;

src/renderer/coremods/notices/plaintextPatches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default [
66
find: /hasNotice:\i,sidebarTheme:\i/,
77
replacements: [
88
{
9-
match: /\i\.base,"data-fullscreen":\i,children:\[/,
9+
match: /\.\i,"data-fullscreen":\i,children:\[/,
1010
replace: `$&$exports?.AnnouncementContainer?.(),`,
1111
},
1212
],

0 commit comments

Comments
 (0)