From e276d9a2b9e33a3e1e7df80735d415278faea4a8 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Thu, 29 May 2025 20:51:30 +0700 Subject: [PATCH] Fix "disableGamepadDisconnectedScreen" patch --- dist/better-xcloud.pretty.user.js | 5 +++-- dist/better-xcloud.user.js | 2 +- src/modules/patcher/patcher.ts | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dist/better-xcloud.pretty.user.js b/dist/better-xcloud.pretty.user.js index 9267a51..5c0bf48 100644 --- a/dist/better-xcloud.pretty.user.js +++ b/dist/better-xcloud.pretty.user.js @@ -5256,8 +5256,9 @@ logFunc(logTag, '//', logMessage); disableGamepadDisconnectedScreen(str) { let index = str.indexOf('"GamepadDisconnected_Title",'); if (index < 0) return !1; - let constIndex = str.indexOf("const", index - 30); - return str = str.substring(0, constIndex) + "e.onClose();return null;" + str.substring(constIndex), str; + let constIndex = PatcherUtils.lastIndexOf(str, "const[", index, 100); + if (constIndex < 0) return !1; + return str = PatcherUtils.insertAt(str, constIndex, "debugger;e();return null;"), console.log(str), str; }, patchUpdateInputConfigurationAsync(str) { let text = "async updateInputConfigurationAsync(e){"; diff --git a/dist/better-xcloud.user.js b/dist/better-xcloud.user.js index ca521d5..7f9f36a 100755 --- a/dist/better-xcloud.user.js +++ b/dist/better-xcloud.user.js @@ -161,7 +161,7 @@ var LOG_TAG2 = "Patcher", PATCHES = {disableAiTrack(str) {let text = ".track=fun const [logTag, logLevel, logMessage] = Array.from(arguments); const logFunc = [console.debug, console.log, console.warn, console.error][logLevel]; logFunc(logTag, '//', logMessage); -`;return str = PatcherUtils.insertAt(str, index, newCode), str;},enableConsoleLogging(str) {let text = "static isConsoleLoggingAllowed(){";if (!str.includes(text)) return !1;return str = str.replaceAll(text, text + "return true;"), str;},playVibration(str) {let text = "}playVibration(e){";if (!str.includes(text)) return !1;return str = str.replaceAll(text, text + vibration_adjust_default), str;},disableGamepadDisconnectedScreen(str) {let index = str.indexOf('"GamepadDisconnected_Title",');if (index < 0) return !1;let constIndex = str.indexOf("const", index - 30);return str = str.substring(0, constIndex) + "e.onClose();return null;" + str.substring(constIndex), str;},patchUpdateInputConfigurationAsync(str) {let text = "async updateInputConfigurationAsync(e){";if (!str.includes(text)) return !1;let newCode = "e.enableTouchInput = true;";return str = str.replace(text, text + newCode), str;},disableStreamGate(str) {let index = str.indexOf('case"partially-ready":');if (index < 0) return !1;let bracketIndex = str.indexOf("=>{", index - 150) + 3;return str = str.substring(0, bracketIndex) + "return 0;" + str.substring(bracketIndex), str;},exposeTouchLayoutManager(str) {let text = "this._perScopeLayoutsStream=new";if (!str.includes(text)) return !1;let newCode = ` +`;return str = PatcherUtils.insertAt(str, index, newCode), str;},enableConsoleLogging(str) {let text = "static isConsoleLoggingAllowed(){";if (!str.includes(text)) return !1;return str = str.replaceAll(text, text + "return true;"), str;},playVibration(str) {let text = "}playVibration(e){";if (!str.includes(text)) return !1;return str = str.replaceAll(text, text + vibration_adjust_default), str;},disableGamepadDisconnectedScreen(str) {let index = str.indexOf('"GamepadDisconnected_Title",');if (index < 0) return !1;let constIndex = PatcherUtils.lastIndexOf(str, "const[", index, 100);if (constIndex < 0) return !1;return str = PatcherUtils.insertAt(str, constIndex, "debugger;e();return null;"), console.log(str), str;},patchUpdateInputConfigurationAsync(str) {let text = "async updateInputConfigurationAsync(e){";if (!str.includes(text)) return !1;let newCode = "e.enableTouchInput = true;";return str = str.replace(text, text + newCode), str;},disableStreamGate(str) {let index = str.indexOf('case"partially-ready":');if (index < 0) return !1;let bracketIndex = str.indexOf("=>{", index - 150) + 3;return str = str.substring(0, bracketIndex) + "return 0;" + str.substring(bracketIndex), str;},exposeTouchLayoutManager(str) {let text = "this._perScopeLayoutsStream=new";if (!str.includes(text)) return !1;let newCode = ` true; window.BX_EXPOSED["touchLayoutManager"] = this; window.dispatchEvent(new Event("${BxEvent.TOUCH_LAYOUT_MANAGER_READY}")); diff --git a/src/modules/patcher/patcher.ts b/src/modules/patcher/patcher.ts index 0231a5a..32a2564 100755 --- a/src/modules/patcher/patcher.ts +++ b/src/modules/patcher/patcher.ts @@ -237,8 +237,12 @@ logFunc(logTag, '//', logMessage); return false; } - const constIndex = str.indexOf('const', index - 30); - str = str.substring(0, constIndex) + 'e.onClose();return null;' + str.substring(constIndex); + const constIndex = PatcherUtils.lastIndexOf(str, 'const[', index, 100); + if (constIndex < 0) { + return false; + } + + str = PatcherUtils.insertAt(str, constIndex, 'e();return null;'); return str; },