this repo has no description
1import { Patch } from "@moonlight-mod/types"; 2 3const notXssDefensesOnly = () => 4 (moonlight.getConfigOption<boolean>("quietLoggers", "xssDefensesOnly") ?? 5 false) === false; 6 7// These patches MUST run before the simple patches, these are to remove loggers 8// that end up causing syntax errors by the normal patch 9const loggerFixes: Patch[] = [ 10 { 11 find: '"./gg-sans/ggsans-800-extrabolditalic.woff2":', 12 replace: { 13 match: /var .=Error.+?;throw .+?,./, 14 replacement: "" 15 } 16 }, 17 { 18 find: '("GatewaySocket")', 19 replace: { 20 match: /.\.(info|log)(\(.+?\))(;|,)/g, 21 replacement: (_, type, body, trail) => `(()=>{})${body}${trail}` 22 } 23 } 24]; 25loggerFixes.forEach((patch) => { 26 patch.prerequisite = notXssDefensesOnly; 27}); 28 29// Patches to simply remove a logger call 30const stubPatches = [ 31 // "sh" is not a valid locale. 32 [ 33 "is not a valid locale", 34 /(.)\.error\(""\.concat\((.)," is not a valid locale\."\)\)/g 35 ], 36 ['="RunningGameStore"', /.\.info\("games",{.+?}\),/], 37 [ 38 '"[BUILD INFO] Release Channel: "', 39 /new .{1,2}\.Z\(\)\.log\("\[BUILD INFO\] Release Channel: ".+?"\)\),/ 40 ], 41 [ 42 '.APP_NATIVE_CRASH,"Storage"', 43 /console\.log\("AppCrashedFatalReport lastCrash:",.,.\);/ 44 ], 45 [ 46 '.APP_NATIVE_CRASH,"Storage"', 47 'console.log("AppCrashedFatalReport: getLastCrash not supported.");' 48 ], 49 ['"[NATIVE INFO] ', /new .{1,2}\.Z\(\)\.log\("\[NATIVE INFO] .+?\)\);/], 50 ['"Spellchecker"', /.\.info\("Switching to ".+?"\(unavailable\)"\);?/g], 51 [ 52 'throw Error("Messages are still loading.");', 53 /console\.warn\("Unsupported Locale",.\),/ 54 ], 55 ["}_dispatchWithDevtools(", /.\.totalTime>100&&.\.verbose\(.+?\);/], 56 [ 57 '"NativeDispatchUtils"', 58 /null==.&&.\.warn\("Tried getting Dispatch instance before instantiated"\),/ 59 ], 60 ['("DatabaseManager")', /.\.log\("removing database \(user: ".+?\)\),/], 61 [ 62 '"Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch. Action: "', 63 /.\.has\(.\.type\)&&.\.log\(.+?\.type\)\),/ 64 ], 65 [ 66 'console.warn("Window state not initialized"', 67 /console\.warn\("Window state not initialized",.\),/ 68 ] 69]; 70 71const simplePatches = [ 72 // Moment.js deprecation warnings 73 ["suppressDeprecationWarnings=!1", "suppressDeprecationWarnings=!0"], 74 75 // Zustand related 76 [ 77 /console\.warn\("\[DEPRECATED\] Please use `subscribeWithSelector` middleware"\)/g, 78 "/*$&*/" 79 ], 80 ["this.getDebugLogging()", "false"] 81] as { [0]: string | RegExp; [1]: string }[]; 82 83export const patches: Patch[] = [ 84 { 85 find: ".Messages.XSSDefenses", 86 replace: { 87 match: /\(null!=.{1,2}&&"0\.0\.0"===.{1,2}\.remoteApp\.getVersion\(\)\)/, 88 replacement: "(true)" 89 } 90 }, 91 ...loggerFixes, 92 ...stubPatches.map((patch) => ({ 93 find: patch[0], 94 replace: { 95 match: patch[1], 96 replacement: "" 97 }, 98 prerequisite: notXssDefensesOnly 99 })), 100 ...simplePatches.map((patch) => ({ 101 find: patch[0], 102 replace: { 103 match: patch[0], 104 replacement: patch[1] 105 }, 106 prerequisite: notXssDefensesOnly 107 })) 108];