mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 07:37:19 +02:00
Remove non-cloud games from touch games list
This commit is contained in:
parent
7eda0b61cc
commit
c2efbd9c1d
@ -10,8 +10,6 @@ import { BxLogger } from "@utils/bx-logger";
|
||||
|
||||
const LOG_TAG = 'TouchController';
|
||||
|
||||
export const GALLERY_TOUCH_GAMES = '9c86f07a-f3e8-45ad-82a0-a1f759597059';
|
||||
|
||||
export class TouchController {
|
||||
static readonly #EVENT_SHOW_DEFAULT_CONTROLLER = new MessageEvent('message', {
|
||||
data: '{"content":"{\\"layoutId\\":\\"\\"}","target":"/streaming/touchcontrols/showlayoutv2","type":"Message"}',
|
||||
|
4
src/utils/gamepass-gallery.ts
Normal file
4
src/utils/gamepass-gallery.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export enum GamePassCloudGallery {
|
||||
TOUCH = '9c86f07a-f3e8-45ad-82a0-a1f759597059',
|
||||
ALL = '29a81209-df6f-41fd-a528-2ae6b91f719c',
|
||||
}
|
@ -4,9 +4,10 @@ import { LoadingScreen } from "@modules/loading-screen";
|
||||
import { PrefKey, getPref } from "@utils/preferences";
|
||||
import { RemotePlay } from "@modules/remote-play";
|
||||
import { StreamBadges } from "@modules/stream/stream-badges";
|
||||
import { GALLERY_TOUCH_GAMES, TouchController } from "@modules/touch-controller";
|
||||
import { TouchController } from "@modules/touch-controller";
|
||||
import { STATES } from "@utils/global";
|
||||
import { getPreferredServerRegion } from "@utils/region";
|
||||
import { GamePassCloudGallery } from "./gamepass-gallery";
|
||||
|
||||
export const NATIVE_FETCH = window.fetch;
|
||||
|
||||
@ -526,6 +527,8 @@ export function interceptHttpRequests() {
|
||||
return nativeXhrSend.apply(this, arguments);
|
||||
};
|
||||
|
||||
let gamepassAllGames: string[] = [];
|
||||
|
||||
(window as any).BX_FETCH = window.fetch = async (request: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
||||
let url = (typeof request === 'string') ? request : (request as Request).url;
|
||||
|
||||
@ -550,14 +553,27 @@ export function interceptHttpRequests() {
|
||||
}
|
||||
|
||||
// Add list of games with custom layouts to the official list
|
||||
if (url.includes('catalog.gamepass.com') && url.includes(GALLERY_TOUCH_GAMES)) {
|
||||
if (STATES.hasTouchSupport && url.includes('catalog.gamepass.com/sigls/')) {
|
||||
const response = await NATIVE_FETCH(request, init);
|
||||
const obj = await response.clone().json();
|
||||
|
||||
try {
|
||||
const customList = TouchController.getCustomList().map(item => ({ id: item }));
|
||||
obj.push(...customList);
|
||||
} catch (e) {}
|
||||
if (url.includes(GamePassCloudGallery.ALL)) {
|
||||
debugger;
|
||||
for (let i = 1; i < obj.length; i++) {
|
||||
gamepassAllGames.push(obj[i].id);
|
||||
}
|
||||
} else if (url.includes(GamePassCloudGallery.TOUCH)) {
|
||||
debugger;
|
||||
try {
|
||||
let customList = TouchController.getCustomList();
|
||||
|
||||
// Remove non-cloud games from the list
|
||||
customList = customList.filter(id => gamepassAllGames.includes(id));
|
||||
|
||||
const newCustomList = customList.map(item => ({ id: item }));
|
||||
obj.push(...newCustomList);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
response.json = () => Promise.resolve(obj);
|
||||
return response;
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { STATES } from "@utils/global";
|
||||
import { UserAgent } from "@utils/user-agent";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
import { GALLERY_TOUCH_GAMES, TouchController } from "@modules/touch-controller";
|
||||
import { TouchController } from "@modules/touch-controller";
|
||||
import { GamePassCloudGallery } from "./gamepass-gallery";
|
||||
|
||||
const LOG_TAG = 'PreloadState';
|
||||
|
||||
@ -29,10 +30,19 @@ export function overridePreloadState() {
|
||||
// Add list of games with custom layouts to the official list
|
||||
if (STATES.hasTouchSupport) {
|
||||
TouchController.updateCustomList();
|
||||
const customList = TouchController.getCustomList();
|
||||
let customList = TouchController.getCustomList();
|
||||
|
||||
try {
|
||||
state.xcloud.sigls[GALLERY_TOUCH_GAMES]?.data.products.push(...customList);
|
||||
const sigls = state.xcloud.sigls;
|
||||
if (GamePassCloudGallery.TOUCH in sigls) {
|
||||
const allGames = sigls[GamePassCloudGallery.ALL].data.products;
|
||||
|
||||
// Remove non-cloud games from the list
|
||||
customList = customList.filter(id => allGames.includes(id));
|
||||
|
||||
// Add to the official list
|
||||
sigls[GamePassCloudGallery.TOUCH]?.data.products.push(...customList);
|
||||
}
|
||||
} catch (e) {
|
||||
BxLogger.error(LOG_TAG, e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user