Skip to content

Commit

Permalink
Update Guide menu detection
Browse files Browse the repository at this point in the history
  • Loading branch information
redphx committed Jun 10, 2024
1 parent 00ebb3f commit 3a16187
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,18 @@ function observeRootDialog($root: HTMLElement) {
const $addedElm = mutation.addedNodes[0];
if ($addedElm instanceof HTMLElement && $addedElm.className) {
if ($addedElm.className.startsWith('NavigationAnimation') || $addedElm.className.startsWith('DialogRoutes') || $addedElm.className.startsWith('Dialog-module__container')) {
// Find navigation bar
const $selectedTab = $addedElm.querySelector('div[class^=NavigationMenu] button[aria-selected=true');
if ($selectedTab) {
let $elm: Element | null = $selectedTab;
let index;
for (index = 0; ($elm = $elm?.previousElementSibling); index++);

if (index === 0) {
BxEvent.dispatch(window, BxEvent.XCLOUD_GUIDE_MENU_SHOWN, {where: GuideMenuTab.HOME});
// Make sure it's Guide dialog
if (document.querySelector('#gamepass-dialog-root div[class*=GuideDialog]')) {
// Find navigation bar
const $selectedTab = $addedElm.querySelector('div[class^=NavigationMenu] button[aria-selected=true');
if ($selectedTab) {
let $elm: Element | null = $selectedTab;
let index;
for (index = 0; ($elm = $elm?.previousElementSibling); index++);

if (index === 0) {
BxEvent.dispatch(window, BxEvent.XCLOUD_GUIDE_MENU_SHOWN, {where: GuideMenuTab.HOME});
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/bx-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export namespace BxEvent {
}
}

AppInterface && AppInterface.onEvent(eventName);
target.dispatchEvent(event);
AppInterface && AppInterface.onEvent(eventName);
}
}

Expand Down

0 comments on commit 3a16187

Please sign in to comment.