diff --git a/src/custom-hooks/useQuickAccessVisible.tsx b/src/custom-hooks/useQuickAccessVisible.tsx index 5872b40..973861b 100644 --- a/src/custom-hooks/useQuickAccessVisible.tsx +++ b/src/custom-hooks/useQuickAccessVisible.tsx @@ -6,7 +6,8 @@ declare global { function getQuickAccessWindow(): Window | null { try { - const navTrees = FocusNavController?.m_ActiveContext?.m_rgGamepadNavigationTrees || FocusNavController?.m_rgGamepadNavigationTrees; + const context = FocusNavController?.m_ActiveContext || FocusNavController?.m_LastActiveContext; + const navTrees = context?.m_ActiveContext?.m_rgGamepadNavigationTrees || FocusNavController?.m_rgGamepadNavigationTrees; return navTrees?.find((tree: any) => tree?.id === "QuickAccess-NA")?.m_Root?.m_element?.ownerDocument.defaultView ?? null; } catch (error) { console.error(error); diff --git a/src/utils/index.ts b/src/utils/index.ts index 713a006..d139e36 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -16,6 +16,7 @@ export function findSP(): Window { // old (SP as host) if (document.title == 'SP') return window; // new (SP as popup) - return FocusNavController.m_ActiveContext.m_rgGamepadNavigationTrees.find((x: any) => x.m_ID == 'root_1_').Root + const context = FocusNavController.m_ActiveContext || FocusNavController.m_LastActiveContext; + return context.m_rgGamepadNavigationTrees.find((x: any) => x.m_ID == 'root_1_').Root .Element.ownerDocument.defaultView; }