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