diff --git a/src/modules/patcher.ts b/src/modules/patcher.ts index b15c922..4928014 100644 --- a/src/modules/patcher.ts +++ b/src/modules/patcher.ts @@ -635,6 +635,16 @@ true` + text; str = str.replace(text, 'if (!e) e = "https://www.xbox.com";'); return str; }, + + exposeDialogRoutes(str: string) { + const text = 'return{goBack:function(){'; + if (!str.includes(text)) { + return false; + } + + str = str.replace(text, 'return window.BX_EXPOSED.dialogRoutes = {goBack:function(){'); + return str; + } }; let PATCH_ORDERS: PatchArray = [ @@ -652,6 +662,7 @@ let PATCH_ORDERS: PatchArray = [ 'broadcastPollingMode', 'exposeStreamSession', + 'exposeDialogRoutes', getPref(PrefKey.UI_LAYOUT) !== 'default' && 'websiteLayout', getPref(PrefKey.LOCAL_CO_OP_ENABLED) && 'supportLocalCoOp', diff --git a/src/modules/ui/guide-menu.ts b/src/modules/ui/guide-menu.ts index 6cfba4a..288d9f8 100644 --- a/src/modules/ui/guide-menu.ts +++ b/src/modules/ui/guide-menu.ts @@ -1,7 +1,8 @@ import { BxEvent } from "@/utils/bx-event"; import { AppInterface, STATES } from "@/utils/global"; -import { createButton, ButtonStyle } from "@/utils/html"; +import { createButton, ButtonStyle, CE } from "@/utils/html"; import { t } from "@/utils/translation"; +import { StreamSettings } from "../stream/stream-settings"; export enum GuideMenuTab { HOME, @@ -14,20 +15,52 @@ export class GuideMenu { if (!$dividers) { return; } - const $lastDivider = $dividers[$dividers.length - 1]; - // Add "Close app" button + const buttons = []; + + // "Stream settings" button + buttons.push(createButton({ + label: t('stream-settings'), + style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE, + onClick: e => { + // Close all xCloud's dialogs + window.BX_EXPOSED.dialogRoutes.closeAll(); + + StreamSettings.getInstance().show(); + }, + })); + + // "App settings" & "Close app" buttons if (AppInterface) { - const $btnQuit = createButton({ + buttons.push(createButton({ + label: t('android-app-settings'), + style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE, + onClick: e => { + AppInterface.openAppSettings && AppInterface.openAppSettings(); + }, + })); + + buttons.push(createButton({ label: t('close-app'), style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE | ButtonStyle.DANGER, onClick: e => { AppInterface.closeApp(); }, - }); - - $lastDivider.insertAdjacentElement('afterend', $btnQuit); + })); } + + if (!buttons.length) { + return; + } + + const $div = CE('div', {}); + + for (const $button of buttons) { + $div.appendChild($button); + } + + const $lastDivider = $dividers[$dividers.length - 1]; + $lastDivider.insertAdjacentElement('afterend', $div); } static #injectHomePlaying($root: HTMLElement) {