this repo has no description
1import { Patch, ExtensionWebpackModule } from "@moonlight-mod/types"; 2import { APPLICATION_ID } from "@moonlight-mod/types/coreExtensions/commands"; 3 4export const patches: Patch[] = [ 5 { 6 find: ".fI5MTU)", // COMMAND_SECTION_BUILT_IN_NAME 7 replace: [ 8 // inject commands 9 { 10 match: /return (\i)\.filter/, 11 replacement: (orig, commands) => 12 `return [...${commands},...require("commands_commands").default._getCommands()].filter` 13 }, 14 15 // section 16 { 17 match: /(?<=\i={)(?=\[\i\.\i\.BUILT_IN]:{id:\i\.\i\.BUILT_IN,type:(\i.\i\.BUILT_IN))/, 18 replacement: (_, type) => 19 `"${APPLICATION_ID}":{id:"${APPLICATION_ID}",type:${type},get name(){return "moonlight"}},` 20 } 21 ] 22 }, 23 24 // index our section 25 { 26 find: '"ApplicationCommandIndexStore"', 27 replace: { 28 match: /(?<=let \i=(\i)\((\i\.\i)\[\i\.\i\.BUILT_IN\],(\i),!0,!0,(\i)\);)null!=(\i)&&(\i)\.push\(\i\)/, 29 replacement: (_, createSection, sections, deny, props, section, commands) => 30 `null!=${section}&&(${section}.data=${section}.data.filter(c=>c.applicationId=="-1")); 31 null!=${section}&&${commands}.push(${section}); 32 const moonlightCommands=${createSection}(${sections}["${APPLICATION_ID}"],${deny},!0,!0,${props}); 33 null!=moonlightCommands&&(moonlightCommands.data=moonlightCommands.data.filter(c=>c.applicationId=="${APPLICATION_ID}")); 34 null!=moonlightCommands&&${commands}.push(moonlightCommands)` 35 } 36 }, 37 38 // grab legacy commands (needed for adding actions that act like sed/plus reacting) 39 { 40 find: "={tts:{action:", 41 replace: { 42 match: /Object\.setPrototypeOf\((\i),null\)/, 43 replacement: (_, legacyCommands) => `require("commands_commands")._getLegacyCommands(${legacyCommands})` 44 } 45 }, 46 47 // add icon 48 { 49 find: ",hasSpaceTerminator:", 50 replace: { 51 match: /(\i)\.type===/, 52 replacement: (orig, section) => `${section}.id!=="${APPLICATION_ID}"&&${orig}` 53 } 54 }, 55 { 56 find: ".icon,bot:null===", 57 replace: { 58 match: /(\.useMemo\(\(\)=>{)(if\((\i)\.type)/, 59 replacement: (_, before, after, section) => `${before} 60 if (${section}.id==="${APPLICATION_ID}") return "https://moonlight-mod.github.io/favicon.png"; 61 ${after}` 62 } 63 }, 64 // fix icon sizing because they expect built in to be 24 and others to be 32 65 { 66 find: ".builtInSeparator}):null]", 67 replace: { 68 match: /(\i)\.type===\i\.\i\.BUILT_IN/, 69 replacement: (orig, section) => `${section}.id!=="${APPLICATION_ID}"&&${orig}` 70 } 71 } 72]; 73 74export const webpackModules: Record<string, ExtensionWebpackModule> = { 75 commands: {} 76};