Update dist

This commit is contained in:
redphx 2024-05-07 21:40:28 +07:00
parent c948b63b8d
commit 7eda0b61cc

View File

@ -6557,6 +6557,7 @@ function setupScreenshotButton() {
// src/modules/touch-controller.ts // src/modules/touch-controller.ts
var LOG_TAG2 = "TouchController"; var LOG_TAG2 = "TouchController";
var GALLERY_TOUCH_GAMES = "9c86f07a-f3e8-45ad-82a0-a1f759597059";
class TouchController { class TouchController {
static #EVENT_SHOW_DEFAULT_CONTROLLER = new MessageEvent("message", { static #EVENT_SHOW_DEFAULT_CONTROLLER = new MessageEvent("message", {
@ -6687,6 +6688,14 @@ class TouchController {
}); });
}, delay); }, delay);
} }
static updateCustomList() {
NATIVE_FETCH("https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/touch-layouts/ids.json").then((response) => response.json()).then((json) => {
window.localStorage.setItem("better_xcloud_custom_touch_layouts", JSON.stringify(json));
});
}
static getCustomList() {
return JSON.parse(window.localStorage.getItem("better_xcloud_custom_touch_layouts") || "[]");
}
static setup() { static setup() {
window.BX_EXPOSED.test_touch_control = (layout) => { window.BX_EXPOSED.test_touch_control = (layout) => {
const { touch_layout_manager } = window.BX_EXPOSED; const { touch_layout_manager } = window.BX_EXPOSED;
@ -7663,6 +7672,17 @@ function interceptHttpRequests() {
if (url.endsWith("/configuration")) { if (url.endsWith("/configuration")) {
BxEvent.dispatch(window, BxEvent.STREAM_STARTING); BxEvent.dispatch(window, BxEvent.STREAM_STARTING);
} }
if (url.includes("catalog.gamepass.com") && url.includes(GALLERY_TOUCH_GAMES)) {
const response = await NATIVE_FETCH(request, init);
const obj = await response.clone().json();
try {
const customList = TouchController.getCustomList().map((item2) => ({ id: item2 }));
obj.push(...customList);
} catch (e) {
}
response.json = () => Promise.resolve(obj);
return response;
}
let requestType; let requestType;
if (url.includes("/sessions/home") || url.includes("xhome.") || STATES.remotePlay.isPlaying && url.endsWith("/inputconfigs")) { if (url.includes("/sessions/home") || url.includes("xhome.") || STATES.remotePlay.isPlaying && url.endsWith("/inputconfigs")) {
requestType = RequestType.XHOME; requestType = RequestType.XHOME;
@ -10156,25 +10176,38 @@ function onHistoryChanged(e) {
BxEvent.dispatch(window, BxEvent.STREAM_STOPPED); BxEvent.dispatch(window, BxEvent.STREAM_STOPPED);
} }
// src/utils/titles-info.ts // src/utils/preload-state.ts
class PreloadedState { function overridePreloadState() {
static override() { let _state;
Object.defineProperty(window, "__PRELOADED_STATE__", { Object.defineProperty(window, "__PRELOADED_STATE__", {
configurable: true, configurable: true,
get: () => { get: () => {
const userAgent = UserAgent.spoof(); return _state;
if (userAgent) {
this._state.appContext.requestInfo.userAgent = userAgent;
}
return this._state;
}, },
set: (state) => { set: (state) => {
this._state = state; const userAgent = UserAgent.spoof();
if (userAgent) {
try {
state.appContext.requestInfo.userAgent = userAgent;
} catch (e) {
BxLogger.error(LOG_TAG5, e);
}
}
if (STATES.hasTouchSupport) {
TouchController.updateCustomList();
const customList = TouchController.getCustomList();
try {
state.xcloud.sigls[GALLERY_TOUCH_GAMES]?.data.products.push(...customList);
} catch (e) {
BxLogger.error(LOG_TAG5, e);
}
}
_state = state;
STATES.appContext = structuredClone(state.appContext); STATES.appContext = structuredClone(state.appContext);
} }
}); });
} }
} var LOG_TAG5 = "PreloadState";
// src/utils/monkey-patches.ts // src/utils/monkey-patches.ts
function patchVideoApi() { function patchVideoApi() {
@ -10333,7 +10366,7 @@ var main = function() {
patchCanvasContext(); patchCanvasContext();
getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && patchAudioContext(); getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && patchAudioContext();
getPref(PrefKey.BLOCK_TRACKING) && patchMeControl(); getPref(PrefKey.BLOCK_TRACKING) && patchMeControl();
PreloadedState.override(); overridePreloadState();
VibrationManager.initialSetup(); VibrationManager.initialSetup();
BX_FLAGS.CheckForUpdate && checkForUpdate(); BX_FLAGS.CheckForUpdate && checkForUpdate();
addCss(); addCss();