From 8c446ceec3fbe0ae98df069099b4ad890b26b48c Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sun, 8 Dec 2024 20:26:05 +0700 Subject: [PATCH] Refactor patches --- dist/better-xcloud.lite.user.js | 6 +++++- dist/better-xcloud.user.js | 13 ++++++++----- src/modules/patcher/patcher.ts | 8 +++----- .../patches/set-currently-focused-interactable.js | 1 - 4 files changed, 16 insertions(+), 12 deletions(-) delete mode 100755 src/modules/patcher/patches/set-currently-focused-interactable.js diff --git a/dist/better-xcloud.lite.user.js b/dist/better-xcloud.lite.user.js index 7da4cb3..0f473b7 100755 --- a/dist/better-xcloud.lite.user.js +++ b/dist/better-xcloud.lite.user.js @@ -6192,7 +6192,11 @@ function patchMeControl() { window.MSA = new Proxy(MSA, MsaHandler), window.MeControl = new Proxy(MeControl, MeControlHandler); } function disableAdobeAudienceManager() { - window.adobe = Object.freeze({}); + Object.defineProperty(window, "adobe", { + get() { + return Object.freeze({}); + } + }); } function patchCanvasContext() { let nativeGetContext = HTMLCanvasElement.prototype.getContext; diff --git a/dist/better-xcloud.user.js b/dist/better-xcloud.user.js index 673eb90..d9944c3 100755 --- a/dist/better-xcloud.user.js +++ b/dist/better-xcloud.user.js @@ -4068,7 +4068,6 @@ window.dispatchEvent(new GamepadEvent('gamepadconnected', { gamepad })); } }; window.BX_EXPOSED.toggleLocalCoOp = this.toggleLocalCoOp.bind(this);`; -var set_currently_focused_interactable_default = `e && BxEvent.dispatch(window, BxEvent.NAVIGATION_FOCUS_CHANGED, { element: e });`; var remote_play_enable_default = `connectMode: window.BX_REMOTE_PLAY_CONFIG ? "xhome-connect" : "cloud-connect", remotePlayServerId: (window.BX_REMOTE_PLAY_CONFIG && window.BX_REMOTE_PLAY_CONFIG.serverId) || '',`; var remote_play_keep_alive_default = `const msg = JSON.parse(e); @@ -4246,8 +4245,8 @@ logFunc(logTag, '//', logMessage); if (index < 0) return !1; let endIndex = str.indexOf("},", index), newSettings = JSON.stringify(FeatureGates); newSettings = newSettings.substring(1, newSettings.length - 1); - let newCode = newSettings; - return str = str.substring(0, endIndex) + "," + newCode + str.substring(endIndex), str; + let newCode = "," + newSettings; + return str = PatcherUtils.insertAt(str, endIndex, newCode), str; }, disableGamepadDisconnectedScreen(str) { let index = str.indexOf('"GamepadDisconnected_Title",'); @@ -4533,7 +4532,7 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) { patchSetCurrentlyFocusedInteractable(str) { let index = str.indexOf(".setCurrentlyFocusedInteractable=("); if (index < 0) return !1; - return index = str.indexOf("{", index) + 1, str = str.substring(0, index) + set_currently_focused_interactable_default + str.substring(index), str; + return index = str.indexOf("{", index) + 1, str = PatcherUtils.insertAt(str, index, "e && BxEvent.dispatch(window, BxEvent.NAVIGATION_FOCUS_CHANGED, { element: e });"), str; }, detectProductDetailPage(str) { let index = str.indexOf('{location:"ProductDetailPage",'); @@ -8538,7 +8537,11 @@ function patchMeControl() { window.MSA = new Proxy(MSA, MsaHandler), window.MeControl = new Proxy(MeControl, MeControlHandler); } function disableAdobeAudienceManager() { - window.adobe = Object.freeze({}); + Object.defineProperty(window, "adobe", { + get() { + return Object.freeze({}); + } + }); } function patchCanvasContext() { let nativeGetContext = HTMLCanvasElement.prototype.getContext; diff --git a/src/modules/patcher/patcher.ts b/src/modules/patcher/patcher.ts index 75ed7cb..e68c72d 100755 --- a/src/modules/patcher/patcher.ts +++ b/src/modules/patcher/patcher.ts @@ -7,7 +7,6 @@ import { BxEvent } from "@/utils/bx-event"; import codeControllerShortcuts from "./patches/controller-shortcuts.js" with { type: "text" }; import codeExposeStreamSession from "./patches/expose-stream-session.js" with { type: "text" }; import codeLocalCoOpEnable from "./patches/local-co-op-enable.js" with { type: "text" }; -import codeSetCurrentlyFocusedInteractable from "./patches/set-currently-focused-interactable.js" with { type: "text" }; import codeRemotePlayEnable from "./patches/remote-play-enable.js" with { type: "text" }; import codeRemotePlayKeepAlive from "./patches/remote-play-keep-alive.js" with { type: "text" }; import codeVibrationAdjust from "./patches/vibration-adjust.js" with { type: "text" }; @@ -258,9 +257,8 @@ logFunc(logTag, '//', logMessage); let newSettings = JSON.stringify(FeatureGates); newSettings = newSettings.substring(1, newSettings.length - 1); - const newCode = newSettings; - - str = str.substring(0, endIndex) + ',' + newCode + str.substring(endIndex); + const newCode = ',' + newSettings; + str = PatcherUtils.insertAt(str, endIndex, newCode); return str; }, @@ -852,7 +850,7 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) { } index = str.indexOf('{', index) + 1; - str = str.substring(0, index) + codeSetCurrentlyFocusedInteractable + str.substring(index); + str = PatcherUtils.insertAt(str, index, 'e && BxEvent.dispatch(window, BxEvent.NAVIGATION_FOCUS_CHANGED, { element: e });'); return str; }, diff --git a/src/modules/patcher/patches/set-currently-focused-interactable.js b/src/modules/patcher/patches/set-currently-focused-interactable.js deleted file mode 100755 index b3a2c75..0000000 --- a/src/modules/patcher/patches/set-currently-focused-interactable.js +++ /dev/null @@ -1 +0,0 @@ -e && BxEvent.dispatch(window, BxEvent.NAVIGATION_FOCUS_CHANGED, { element: e });