From 18a8b8330c5c83cf30e698634bc669fc191dfd00 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:07:53 +0700 Subject: [PATCH] Add "patchSetCurrentlyFocusedInteractable" patch --- src/index.ts | 8 ++++++++ src/modules/patcher.ts | 14 ++++++++++++++ .../patches/set-currently-focused-interactable.js | 1 + src/utils/bx-event.ts | 2 ++ 4 files changed, 25 insertions(+) create mode 100644 src/modules/patches/set-currently-focused-interactable.js diff --git a/src/index.ts b/src/index.ts index ca9c84d..2d97a70 100644 --- a/src/index.ts +++ b/src/index.ts @@ -186,6 +186,14 @@ window.addEventListener(BxEvent.STREAM_ERROR_PAGE, e => { BxEvent.dispatch(window, BxEvent.STREAM_STOPPED); }); +window.addEventListener(BxEvent.NAVIGATION_FOCUS_CHANGED, e => { + const $elm = (e as any).element; + if (($elm.tagName === 'BUTTON' && $elm.className.includes('MruGameCard')) || ($elm.tagName === 'A' && $elm.className.includes('GameCard'))) { + console.dir($elm); + } +}); + + function unload() { if (!STATES.isPlaying) { return; diff --git a/src/modules/patcher.ts b/src/modules/patcher.ts index 16e6421..d31e17b 100644 --- a/src/modules/patcher.ts +++ b/src/modules/patcher.ts @@ -9,6 +9,7 @@ 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" }; @@ -775,6 +776,18 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) { str = str.substring(0, commaIndex) + ',true' + str.substring(index); return str; }, + + // 24225.js#4127, 24.17.11 + patchSetCurrentlyFocusedInteractable(str: string) { + let index = str.indexOf('.setCurrentlyFocusedInteractable=('); + if (index === -1) { + return false; + } + + index = str.indexOf('{', index) + 1; + str = str.substring(0, index) + codeSetCurrentlyFocusedInteractable + str.substring(index); + return str; + }, }; let PATCH_ORDERS: PatchArray = [ @@ -797,6 +810,7 @@ let PATCH_ORDERS: PatchArray = [ 'enableTvRoutes', 'overrideStorageGetSettings', + 'patchSetCurrentlyFocusedInteractable', getPref(PrefKey.UI_LAYOUT) !== 'default' && 'websiteLayout', getPref(PrefKey.LOCAL_CO_OP_ENABLED) && 'supportLocalCoOp', diff --git a/src/modules/patches/set-currently-focused-interactable.js b/src/modules/patches/set-currently-focused-interactable.js new file mode 100644 index 0000000..aeb55f5 --- /dev/null +++ b/src/modules/patches/set-currently-focused-interactable.js @@ -0,0 +1 @@ +e && BxEvent.dispatch(window, BxEvent.NAVIGATION_FOCUS_CHANGED, {element: e}); diff --git a/src/utils/bx-event.ts b/src/utils/bx-event.ts index 2bf8162..6b5cdad 100644 --- a/src/utils/bx-event.ts +++ b/src/utils/bx-event.ts @@ -38,6 +38,8 @@ export enum BxEvent { POINTER_LOCK_REQUESTED = 'bx-pointer-lock-requested', POINTER_LOCK_EXITED = 'bx-pointer-lock-exited', + NAVIGATION_FOCUS_CHANGED = 'bx-nav-focus-changed', + // xCloud Dialog events XCLOUD_DIALOG_SHOWN = 'bx-xcloud-dialog-shown', XCLOUD_DIALOG_DISMISSED = 'bx-xcloud-dialog-dismissed',