From e3577e6f5f1db9fb2c2f43b66f50b43c19531e6b Mon Sep 17 00:00:00 2001 From: 1Lighty <49841131+1Lighty@users.noreply.github.com> Date: Wed, 29 Jan 2025 19:48:31 +0100 Subject: [PATCH] 1XL v1.4.19 HOTFIX --- Plugins/1XenoLib.plugin.js | 47 ++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/Plugins/1XenoLib.plugin.js b/Plugins/1XenoLib.plugin.js index 4f55aa0..c9c05fd 100644 --- a/Plugins/1XenoLib.plugin.js +++ b/Plugins/1XenoLib.plugin.js @@ -3,7 +3,7 @@ * @description Simple library to complement plugins with shared code without lowering performance. Also adds needed buttons to some plugins. * @author 1Lighty * @authorId 239513071272329217 - * @version 1.4.18 + * @version 1.4.19 * @invite NYvWdN5 * @donate https://paypal.me/lighty13 * @source https://github.com/1Lighty/BetterDiscordPlugins/blob/master/Plugins/1XenoLib.plugin.js @@ -106,7 +106,7 @@ module.exports = (() => { twitter_username: '' } ], - version: '1.4.18', + version: '1.4.19', description: 'Simple library to complement plugins with shared code without lowering performance. Also adds needed buttons to some plugins.', github: 'https://github.com/1Lighty', github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js' @@ -115,7 +115,7 @@ module.exports = (() => { { title: 'Fixed', type: 'fixed', - items: ['Fixed toggles in plugin settings not appearing (this includes MessageLoggerV2 settings and any others)', 'Part 2 cause it didn\'t work the first time'] + items: ['HOTFIX for not working at all'] } ], defaultConfig: [ @@ -904,8 +904,31 @@ module.exports = (() => { try { - XenoLib.ReactComponents.ButtonOptions = WebpackModules.getByProps('Button', 'ButtonColors'); - XenoLib.ReactComponents.Button = WebpackModules.getByProps('Button', 'ButtonColors').Button; + + const ButtonOptionsRaw = ZLibrary.WebpackModules.getModule(e => { + if (typeof e === 'function') return false; + const possFuncs = Object.values(e); + if (possFuncs.length < 3 || possFuncs.length > 8) return false; + if (!possFuncs.some(e => typeof e === 'object' && e?.BRAND_INVERTED)) return false; + return true; + }) + let ButtonOptions = {}; + for (let item of Object.values(ButtonOptionsRaw)) { + if (item.OUTLINED) ButtonOptions.ButtonLooks = item; + else if (item.BRAND) ButtonOptions.ButtonColors = item; + else if (item.SMALL) ButtonOptions.ButtonSizes = item; + else if (typeof item === 'function') { + const funcString = item.toString(); + if (funcString.includes('.disabledButtonWrapper,')) ButtonOptions.Button = item; + // else if (funcString.match(/to:\w,onClick:\w,onMouseUp:\w/)) ButtonOptions.ButtonLink = item; + // else console.log('Unknown item!', item); + } + //else console.log('Unknown item!', item); + // there is 1 more func called "getButtonStyle" but we don't care about it :v + } + if (ButtonOptions.Button.Link) ButtonOptions.ButtonLink = ButtonOptions.Button.Link; + XenoLib.ReactComponents.ButtonOptions = ButtonOptions; + XenoLib.ReactComponents.Button = ButtonOptions.Button; } catch (e) { Logger.stacktrace('Error getting Button component', e); } @@ -2270,8 +2293,18 @@ module.exports = (() => { } } - const ThemeProvider = WebpackModules.getByProps('RootThemeContextProvider').RootThemeContextProvider; - const useSyncExternalStore = WebpackModules.getByProps('useSyncExternalStore').useSyncExternalStore; + const ThemeProvider = (() => { + let RootThemeContextProvider = null; + WebpackModules.getModule(e => { + const possFuncs = Object.values(e); + if (possFuncs.length < 3 || possFuncs.length > 10) return false; + if (!possFuncs.some(e => typeof e === 'function' && e.toString().includes('useThemeContext must be used within a ThemeContext.Provider'))) return false; + RootThemeContextProvider = possFuncs.find(e => e.toString().match(/theme:\w,primaryColor:\w,secondaryColor:\w,/)); + return true; + }) + return RootThemeContextProvider; + })() || (props => props.children); + // const useSyncExternalStore = WebpackModules.getByProps('useSyncExternalStore').useSyncExternalStore; const ThemeStore = WebpackModules.getModule(m => m.theme); function DiscordThemeProviderWrapper(props) {