this repo has no description
1import { Patch, PatchReplaceType } from "@moonlight-mod/types"; 2import { 3 SettingsSection, 4 Settings as SettingsType 5} from "@moonlight-mod/types/coreExtensions"; 6import { ExtensionWebExports, WebpackModuleFunc } from "@moonlight-mod/types"; 7 8export const patches: Patch[] = [ 9 { 10 find: ".UserSettingsSections.EXPERIMENTS", 11 replace: { 12 match: /\.CUSTOM,element:(.+?)}\];return (.{1,2})/, 13 replacement: (_, lastElement, sections) => 14 `.CUSTOM,element:${lastElement}}];return require("settings_settings")._mutateSections(${sections})` 15 } 16 }, 17 { 18 find: 'navId:"user-settings-cog",', 19 replace: { 20 match: /children:\[(.)\.map\(.+?\),{children:.\((.)\)/, 21 replacement: (orig, sections, section) => 22 `${orig}??${sections}.find(x=>x.section==${section})?._moonlight_submenu?.()` 23 } 24 } 25]; 26 27export const webpackModules: ExtensionWebExports["webpackModules"] = { 28 settings: { 29 run: (module, exports, require) => { 30 const Settings: SettingsType = { 31 ourSections: [], 32 33 addSection: (section, label, element, color = null, pos, notice) => { 34 const data: SettingsSection = { 35 section, 36 label, 37 color, 38 element, 39 pos: pos ?? -4, 40 notice: notice 41 }; 42 43 Settings.ourSections.push(data); 44 return data; 45 }, 46 47 addDivider: (pos = null) => { 48 Settings.ourSections.push({ 49 section: "DIVIDER", 50 pos: pos === null ? -4 : pos 51 }); 52 }, 53 54 addHeader: function (label, pos = null) { 55 Settings.ourSections.push({ 56 section: "HEADER", 57 label: label, 58 pos: pos === null ? -4 : pos 59 }); 60 }, 61 62 _mutateSections: (sections) => { 63 for (const section of Settings.ourSections) { 64 sections.splice( 65 section.pos < 0 ? sections.length + section.pos : section.pos, 66 0, 67 section 68 ); 69 } 70 71 return sections; 72 } 73 }; 74 75 module.exports = Settings; 76 } 77 } 78};