diff --git a/src/utils/index.ts b/src/utils/index.ts index e87b167..a1fd37d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -22,7 +22,7 @@ export function findSP(): Window { if (document.title == 'SP') return window; // new (SP as popup) const navTrees = getGamepadNavigationTrees(); - return navTrees.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument.defaultView; + return navTrees?.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument.defaultView; } /** @@ -38,5 +38,5 @@ export function getFocusNavController(): any { export function getGamepadNavigationTrees(): any { const focusNav = getFocusNavController(); const context = focusNav.m_ActiveContext || focusNav.m_LastActiveContext; - return context.m_rgGamepadNavigationTrees; + return context?.m_rgGamepadNavigationTrees; }