Do A Proper Fix For FakeProfileThemesAndEffects

This commit is contained in:
thororen1234 2025-02-18 11:18:24 -05:00
parent af9a895a5e
commit bbdb4bb5bb
No known key found for this signature in database

View file

@ -24,7 +24,7 @@ function replaceHelper(
const beforeReplace = result; const beforeReplace = result;
result = result.replace( result = result.replace(
canonicalizeMatch(searchRegExp), canonicalizeMatch(searchRegExp),
canonicalizeReplace(replaceString, "FakeProfileThemesAndEffects") canonicalizeReplace(replaceString, "Vencord.Plugins.plugins[\"FakeProfileThemesAndEffects\"]")
); );
if (beforeReplace === result) if (beforeReplace === result)
throw new Error("Replace had no effect: " + searchRegExp); throw new Error("Replace had no effect: " + searchRegExp);
@ -58,7 +58,7 @@ export default definePlugin({
find: '"UserProfileStore"', find: '"UserProfileStore"',
replacement: { replacement: {
match: /([{}]getUserProfile\([^)]*\){return) ?([^}]+)/, match: /([{}]getUserProfile\([^)]*\){return) ?([^}]+)/,
replace: "$1 Vencord.Plugins.plugins[\"FakeProfileThemesAndEffects\"].decodeAboutMeFPTEHook($2)" replace: "$1 $self.decodeAboutMeFPTEHook($2)"
} }
}, },
// Patches ProfileCustomizationPreview // Patches ProfileCustomizationPreview
@ -66,7 +66,7 @@ export default definePlugin({
find: ".EDIT_PROFILE_BANNER})", find: ".EDIT_PROFILE_BANNER})",
replacement: { replacement: {
match: /function \i\((\i)\){/, match: /function \i\((\i)\){/,
replace: "$&Vencord.Plugins.plugins[\"FakeProfileThemesAndEffects\"].profilePreviewHook($1);" replace: "$&$self.profilePreviewHook($1);"
} }
}, },
// Adds the FPTE Builder to the User Profile settings page // Adds the FPTE Builder to the User Profile settings page
@ -74,7 +74,7 @@ export default definePlugin({
find: '"DefaultCustomizationSections"', find: '"DefaultCustomizationSections"',
replacement: { replacement: {
match: /\.sectionsContainer,.*?children:\[/, match: /\.sectionsContainer,.*?children:\[/,
replace: "$&Vencord.Plugins.plugins[\"FakeProfileThemesAndEffects\"].addFPTEBuilder()," replace: "$&$self.addFPTEBuilder(),"
} }
}, },
// Adds the FPTE Builder to the Server Profiles settings page // Adds the FPTE Builder to the Server Profiles settings page
@ -82,7 +82,7 @@ export default definePlugin({
find: '"guild should not be null"', find: '"guild should not be null"',
replacement: { replacement: {
match: /\.sectionsContainer,.*?children:\[(?=.+?[{,]guild:(\i))/, match: /\.sectionsContainer,.*?children:\[(?=.+?[{,]guild:(\i))/,
replace: "$&Vencord.Plugins.plugins[\"FakeProfileThemesAndEffects\"].addFPTEBuilder($1)," replace: "$&$self.addFPTEBuilder($1),"
} }
}, },
// ProfileEffectModal // ProfileEffectModal
@ -93,12 +93,12 @@ export default definePlugin({
// Modal root // Modal root
{ {
match: /(function (\i)\([^)]*\){(?:.(?!function |}$))*className:\i\.modal,(?:.(?!function |}$))*}).*(?=})/, match: /(function (\i)\([^)]*\){(?:.(?!function |}$))*className:\i\.modal,(?:.(?!function |}$))*}).*(?=})/,
replace: (match, func, funcName) => `${match}(()=>{Vencord.Plugins.plugins["FakeProfileThemesAndEffects"].ProfileEffectModal=${funcName};` replace: (match, func, funcName) => `${match}(()=>{$self.ProfileEffectModal=${funcName};`
+ replaceHelper(func, [ + replaceHelper(func, [
// Required for the profile preview to show profile effects // Required for the profile preview to show profile effects
[ [
/(?<=[{,]purchases:.+?}=).+?(?=,\i=|,{\i:|;)/, /(?<=[{,]purchases:.+?}=).+?(?=,\i=|,{\i:|;)/,
"{isFetching:!1,categories:new Map,purchases:Vencord.Plugins.plugins[\"FakeProfileThemesAndEffects\"].usePurchases()}" "{isFetching:!1,categories:new Map,purchases:$self.usePurchases()}"
] ]
]) ])
+ "})()" + "})()"
@ -115,12 +115,12 @@ export default definePlugin({
// Replaces the profile effect list with the modified version // Replaces the profile effect list with the modified version
[ [
/(?<=\.jsxs?\)\()[^,]+(?=,{(?:(?:.(?!\.jsxs?\)))+,)?onSelect:)/, /(?<=\.jsxs?\)\()[^,]+(?=,{(?:(?:.(?!\.jsxs?\)))+,)?onSelect:)/,
"Vencord.Plugins.plugins[\"FakeProfileThemesAndEffects\"].ProfileEffectSelection" "$self.ProfileEffectSelection"
], ],
// Replaces the apply profile effect function with the modified version // Replaces the apply profile effect function with the modified version
[ [
/(?<=[{,]onApply:).*?\)\((\i).*?(?=,\i:|}\))/, /(?<=[{,]onApply:).*?\)\((\i).*?(?=,\i:|}\))/,
"()=>Vencord.Plugins.plugins[\"FakeProfileThemesAndEffects\"].onApply($1)" "()=>$self.onApply($1)"
], ],
// Required to show the apply button // Required to show the apply button
[ [
@ -141,13 +141,13 @@ export default definePlugin({
find: ".presetEffectBackground", find: ".presetEffectBackground",
replacement: { replacement: {
match: /function\(\i,\i,.*?=>(\i).+[,;}]\1=([^=].+?})(?=;|}$).*(?=}$)/, match: /function\(\i,\i,.*?=>(\i).+[,;}]\1=([^=].+?})(?=;|}$).*(?=}$)/,
replace: (match, _, func) => `${match};Vencord.Plugins.plugins["FakeProfileThemesAndEffects"].ProfileEffectSelection=` replace: (match, _, func) => `${match};$self.ProfileEffectSelection=`
+ replaceHelper(func, [ + replaceHelper(func, [
// Removes the "Exclusive to Nitro" and "Preview The Shop" sections // Removes the "Exclusive to Nitro" and "Preview The Shop" sections
// Adds every profile effect to the "Your Decorations" section and removes the "Shop" button // Adds every profile effect to the "Your Decorations" section and removes the "Shop" button
[ [
/(?<=[ ,](\i)=).+?(?=(?:,\i=|,{\i:|;).+?:\1\.map\()/, /(?<=[ ,](\i)=).+?(?=(?:,\i=|,{\i:|;).+?:\1\.map\()/,
"Vencord.Plugins.plugins[\"FakeProfileThemesAndEffects\"].useProfileEffectSections($&)" "$self.useProfileEffectSections($&)"
] ]
]) ])
} }