mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Add FeatureGates
This commit is contained in:
parent
902918d7fb
commit
ebb4d3c141
@ -11,6 +11,7 @@ import codeLocalCoOpEnable from "./patches/local-co-op-enable.js" with { type: "
|
|||||||
import codeRemotePlayEnable from "./patches/remote-play-enable.js" with { type: "text" };
|
import codeRemotePlayEnable from "./patches/remote-play-enable.js" with { type: "text" };
|
||||||
import codeRemotePlayKeepAlive from "./patches/remote-play-keep-alive.js" with { type: "text" };
|
import codeRemotePlayKeepAlive from "./patches/remote-play-keep-alive.js" with { type: "text" };
|
||||||
import codeVibrationAdjust from "./patches/vibration-adjust.js" with { type: "text" };
|
import codeVibrationAdjust from "./patches/vibration-adjust.js" with { type: "text" };
|
||||||
|
import { FeatureGates } from "@/utils/feature-gates.js";
|
||||||
|
|
||||||
type PatchArray = (keyof typeof PATCHES)[];
|
type PatchArray = (keyof typeof PATCHES)[];
|
||||||
|
|
||||||
@ -228,12 +229,10 @@ if (!!window.BX_REMOTE_PLAY_CONFIG) {
|
|||||||
// Find the next "},"
|
// Find the next "},"
|
||||||
const endIndex = str.indexOf('},', index);
|
const endIndex = str.indexOf('},', index);
|
||||||
|
|
||||||
const newSettings = [
|
let newSettings = JSON.stringify(FeatureGates);
|
||||||
// 'EnableStreamGate: false',
|
newSettings = newSettings.substring(1, newSettings.length - 1);
|
||||||
'PwaPrompt: false',
|
|
||||||
];
|
|
||||||
|
|
||||||
const newCode = newSettings.join(',');
|
const newCode = newSettings;
|
||||||
|
|
||||||
str = str.substring(0, endIndex) + ',' + newCode + str.substring(endIndex);
|
str = str.substring(0, endIndex) + ',' + newCode + str.substring(endIndex);
|
||||||
return str;
|
return str;
|
||||||
|
@ -23,7 +23,7 @@ export const BxExposed = {
|
|||||||
|
|
||||||
let supportedInputTypes = titleInfo.details.supportedInputTypes;
|
let supportedInputTypes = titleInfo.details.supportedInputTypes;
|
||||||
|
|
||||||
if (BX_FLAGS.ForceNativeMkbTitles.includes(titleInfo.details.productId)) {
|
if (BX_FLAGS.ForceNativeMkbTitles?.includes(titleInfo.details.productId)) {
|
||||||
supportedInputTypes.push(InputType.MKB);
|
supportedInputTypes.push(InputType.MKB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ type BxFlags = Partial<{
|
|||||||
UseDevTouchLayout: boolean;
|
UseDevTouchLayout: boolean;
|
||||||
|
|
||||||
ForceNativeMkbTitles: string[];
|
ForceNativeMkbTitles: string[];
|
||||||
|
FeatureGates: {[key: string]: boolean} | null,
|
||||||
}>
|
}>
|
||||||
|
|
||||||
// Setup flags
|
// Setup flags
|
||||||
@ -21,9 +22,10 @@ const DEFAULT_FLAGS: BxFlags = {
|
|||||||
UseDevTouchLayout: false,
|
UseDevTouchLayout: false,
|
||||||
|
|
||||||
ForceNativeMkbTitles: [],
|
ForceNativeMkbTitles: [],
|
||||||
|
FeatureGates: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BX_FLAGS = Object.assign(DEFAULT_FLAGS, window.BX_FLAGS || {});
|
export const BX_FLAGS: BxFlags = Object.assign(DEFAULT_FLAGS, window.BX_FLAGS || {});
|
||||||
try {
|
try {
|
||||||
delete window.BX_FLAGS;
|
delete window.BX_FLAGS;
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
20
src/utils/feature-gates.ts
Normal file
20
src/utils/feature-gates.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { BX_FLAGS } from "./bx-flags";
|
||||||
|
import { getPref, PrefKey } from "./preferences";
|
||||||
|
|
||||||
|
export let FeatureGates: {[key: string]: boolean} = {
|
||||||
|
'PwaPrompt': false,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Disable context menu in Home page
|
||||||
|
if (getPref(PrefKey.UI_HOME_CONTEXT_MENU_DISABLED)) {
|
||||||
|
FeatureGates['EnableHomeContextMenu'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable chat feature
|
||||||
|
if (getPref(PrefKey.BLOCK_SOCIAL_FEATURES)) {
|
||||||
|
FeatureGates['EnableGuideChatTab'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BX_FLAGS.FeatureGates) {
|
||||||
|
FeatureGates = Object.assign(BX_FLAGS.FeatureGates, FeatureGates);
|
||||||
|
}
|
@ -9,6 +9,7 @@ import { STATES } from "@utils/global";
|
|||||||
import { getPreferredServerRegion } from "@utils/region";
|
import { getPreferredServerRegion } from "@utils/region";
|
||||||
import { GamePassCloudGallery } from "./gamepass-gallery";
|
import { GamePassCloudGallery } from "./gamepass-gallery";
|
||||||
import { InputType } from "./bx-exposed";
|
import { InputType } from "./bx-exposed";
|
||||||
|
import { FeatureGates } from "./feature-gates";
|
||||||
|
|
||||||
enum RequestType {
|
enum RequestType {
|
||||||
XCLOUD = 'xcloud',
|
XCLOUD = 'xcloud',
|
||||||
@ -440,7 +441,7 @@ class XcloudInterceptor {
|
|||||||
|
|
||||||
let overrideMkb: boolean | null = null;
|
let overrideMkb: boolean | null = null;
|
||||||
|
|
||||||
if (getPref(PrefKey.NATIVE_MKB_ENABLED) === 'on' || BX_FLAGS.ForceNativeMkbTitles.includes(STATES.currentStream.titleInfo!.details.productId)) {
|
if (getPref(PrefKey.NATIVE_MKB_ENABLED) === 'on' || BX_FLAGS.ForceNativeMkbTitles?.includes(STATES.currentStream.titleInfo!.details.productId)) {
|
||||||
overrideMkb = true;
|
overrideMkb = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,14 +579,8 @@ export function interceptHttpRequests() {
|
|||||||
const response = await NATIVE_FETCH(request, init);
|
const response = await NATIVE_FETCH(request, init);
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
|
||||||
const overrideTreatments: {[key: string]: boolean} = {};
|
for (const key in FeatureGates) {
|
||||||
|
json.exp.treatments[key] = FeatureGates[key]
|
||||||
if (getPref(PrefKey.UI_HOME_CONTEXT_MENU_DISABLED)) {
|
|
||||||
overrideTreatments['EnableHomeContextMenu'] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const key in overrideTreatments) {
|
|
||||||
json.exp.treatments[key] = overrideTreatments[key]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response.json = () => Promise.resolve(json);
|
response.json = () => Promise.resolve(json);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user