Add "Disable features" setting

This commit is contained in:
redphx 2024-12-10 21:30:21 +07:00
parent f0549b388a
commit b84c464066
10 changed files with 111 additions and 59 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -63,7 +63,7 @@ export const enum PrefKey {
SCREENSHOT_APPLY_FILTERS = 'screenshot.applyFilters', SCREENSHOT_APPLY_FILTERS = 'screenshot.applyFilters',
BLOCK_TRACKING = 'block.tracking', BLOCK_TRACKING = 'block.tracking',
BLOCK_SOCIAL_FEATURES = 'block.social', BLOCK_FEATURES = 'block.features',
LOADING_SCREEN_GAME_ART = 'loadingScreen.gameArt.show', LOADING_SCREEN_GAME_ART = 'loadingScreen.gameArt.show',
LOADING_SCREEN_SHOW_WAIT_TIME = 'loadingScreen.waitTime.show', LOADING_SCREEN_SHOW_WAIT_TIME = 'loadingScreen.waitTime.show',
@ -73,7 +73,6 @@ export const enum PrefKey {
UI_LAYOUT = 'ui.layout', UI_LAYOUT = 'ui.layout',
UI_SCROLLBAR_HIDE = 'ui.hideScrollbar', UI_SCROLLBAR_HIDE = 'ui.hideScrollbar',
UI_HIDE_SECTIONS = 'ui.hideSections', UI_HIDE_SECTIONS = 'ui.hideSections',
BYOG_DISABLED = 'feature.byog.disabled',
UI_GAME_CARD_SHOW_WAIT_TIME = 'ui.gameCard.waitTime.show', UI_GAME_CARD_SHOW_WAIT_TIME = 'ui.gameCard.waitTime.show',
UI_SIMPLIFY_STREAM_MENU = 'ui.streamMenu.simplify', UI_SIMPLIFY_STREAM_MENU = 'ui.streamMenu.simplify',

View File

@ -110,3 +110,11 @@ export const enum StreamVideoProcessing {
USM = 'usm', USM = 'usm',
CAS = 'cas', CAS = 'cas',
} }
export const enum BlockFeature {
CHAT = 'chat',
FRIENDS = 'friends',
BYOG = 'byog',
NOTIFICATIONS_INVITES = 'notifications-invites',
NOTIFICATIONS_ACHIEVEMENTS = 'notifications-achievements',
}

View File

@ -282,12 +282,14 @@ export class SettingsDialog extends NavigationDialog {
PrefKey.UI_HIDE_SYSTEM_MENU_ICON, PrefKey.UI_HIDE_SYSTEM_MENU_ICON,
PrefKey.UI_DISABLE_FEEDBACK_DIALOG, PrefKey.UI_DISABLE_FEEDBACK_DIALOG,
PrefKey.UI_REDUCE_ANIMATIONS, PrefKey.UI_REDUCE_ANIMATIONS,
PrefKey.BLOCK_SOCIAL_FEATURES,
PrefKey.BYOG_DISABLED,
{ {
pref: PrefKey.UI_HIDE_SECTIONS, pref: PrefKey.UI_HIDE_SECTIONS,
multiLines: true, multiLines: true,
}, },
{
pref: PrefKey.BLOCK_FEATURES,
multiLines: true,
},
], ],
}, { }, {
requiredVariants: 'full', requiredVariants: 'full',

View File

@ -1,6 +1,6 @@
import { CE } from "@utils/html"; import { CE } from "@utils/html";
import { compressCss, renderStylus } from "@macros/build" with { type: "macro" }; import { compressCss, renderStylus } from "@macros/build" with { type: "macro" };
import { UiSection } from "@/enums/pref-values"; import { BlockFeature, UiSection } from "@/enums/pref-values";
import { PrefKey } from "@/enums/pref-keys"; import { PrefKey } from "@/enums/pref-keys";
import { getPref } from "./settings-storages/global-settings-storage"; import { getPref } from "./settings-storages/global-settings-storage";
@ -18,7 +18,7 @@ export function addCss() {
} }
// Hide BYOG section // Hide BYOG section
if (getPref(PrefKey.BYOG_DISABLED)) { if (getPref<BlockFeature[]>(PrefKey.BLOCK_FEATURES).includes(BlockFeature.BYOG)) {
selectorToHide.push('#BodyContent > div[class*=ByogRow-module__container___]'); selectorToHide.push('#BodyContent > div[class*=ByogRow-module__container___]');
} }
@ -39,7 +39,7 @@ export function addCss() {
} }
// Hide "Start a party" button in the Guide menu // Hide "Start a party" button in the Guide menu
if (getPref(PrefKey.BLOCK_SOCIAL_FEATURES)) { if (getPref<BlockFeature[]>(PrefKey.BLOCK_FEATURES).includes(BlockFeature.FRIENDS)) {
selectorToHide.push('#gamepass-dialog-root div[class^=AchievementsPreview-module__container] + button[class*=HomeLandingPage-module__button]'); selectorToHide.push('#gamepass-dialog-root div[class^=AchievementsPreview-module__container] + button[class*=HomeLandingPage-module__button]');
} }

View File

@ -1,7 +1,7 @@
import { PrefKey } from "@/enums/pref-keys"; import { PrefKey } from "@/enums/pref-keys";
import { BX_FLAGS } from "./bx-flags"; import { BX_FLAGS } from "./bx-flags";
import { getPref } from "./settings-storages/global-settings-storage"; import { getPref } from "./settings-storages/global-settings-storage";
import { NativeMkbMode } from "@/enums/pref-values"; import { BlockFeature, NativeMkbMode } from "@/enums/pref-values";
export let FeatureGates: { [key: string]: boolean } = { export let FeatureGates: { [key: string]: boolean } = {
PwaPrompt: false, PwaPrompt: false,
@ -17,13 +17,17 @@ if (nativeMkbMode !== NativeMkbMode.DEFAULT) {
} }
// Disable chat feature // Disable chat feature
if (getPref(PrefKey.BLOCK_SOCIAL_FEATURES)) { const blockFeatures = getPref<BlockFeature[]>(PrefKey.BLOCK_FEATURES);
if (blockFeatures.includes(BlockFeature.CHAT)) {
FeatureGates.EnableGuideChatTab = false; FeatureGates.EnableGuideChatTab = false;
}
if (blockFeatures.includes(BlockFeature.FRIENDS)) {
FeatureGates.EnableFriendsAndFollowers = false; FeatureGates.EnableFriendsAndFollowers = false;
} }
// Disable BYOG feature // Disable BYOG feature
if (getPref(PrefKey.BYOG_DISABLED)) { if (blockFeatures.includes(BlockFeature.BYOG)) {
FeatureGates.EnableBYOG = false; FeatureGates.EnableBYOG = false;
FeatureGates.EnableBYOGPurchase = false; FeatureGates.EnableBYOGPurchase = false;
} }

View File

@ -11,7 +11,7 @@ import { XcloudInterceptor } from "./xcloud-interceptor";
import { PrefKey } from "@/enums/pref-keys"; import { PrefKey } from "@/enums/pref-keys";
import { getPref } from "./settings-storages/global-settings-storage"; import { getPref } from "./settings-storages/global-settings-storage";
import type { RemotePlayConsoleAddresses } from "@/types/network"; import type { RemotePlayConsoleAddresses } from "@/types/network";
import { StreamResolution } from "@/enums/pref-values"; import { BlockFeature, StreamResolution } from "@/enums/pref-values";
type RequestType = 'xcloud' | 'xhome'; type RequestType = 'xcloud' | 'xhome';
@ -137,13 +137,20 @@ export function interceptHttpRequests() {
]); ]);
} }
if (getPref(PrefKey.BLOCK_SOCIAL_FEATURES)) {
// 'https://notificationinbox.xboxlive.com',
// 'https://accounts.xboxlive.com/family/memberXuid',
const blockFeatures = getPref<BlockFeature[]>(PrefKey.BLOCK_FEATURES);
if (blockFeatures.includes(BlockFeature.CHAT)) {
BLOCKED_URLS = BLOCKED_URLS.concat([
'https://xblmessaging.xboxlive.com/network/xbox/users/me/inbox',
]);
}
if (blockFeatures.includes(BlockFeature.FRIENDS)) {
BLOCKED_URLS = BLOCKED_URLS.concat([ BLOCKED_URLS = BLOCKED_URLS.concat([
'https://peoplehub.xboxlive.com/users/me/people/social', 'https://peoplehub.xboxlive.com/users/me/people/social',
'https://peoplehub.xboxlive.com/users/me/people/recommendations', 'https://peoplehub.xboxlive.com/users/me/people/recommendations',
'https://xblmessaging.xboxlive.com/network/xbox/users/me/inbox',
// 'https://notificationinbox.xboxlive.com',
// 'https://accounts.xboxlive.com/family/memberXuid',
]); ]);
} }

View File

@ -8,7 +8,7 @@ import { CE } from "../html";
import { t, SUPPORTED_LANGUAGES } from "../translation"; import { t, SUPPORTED_LANGUAGES } from "../translation";
import { UserAgent } from "../user-agent"; import { UserAgent } from "../user-agent";
import { BaseSettingsStore as BaseSettingsStorage } from "./base-settings-storage"; import { BaseSettingsStore as BaseSettingsStorage } from "./base-settings-storage";
import { CodecProfile, StreamResolution, TouchControllerMode, TouchControllerStyleStandard, TouchControllerStyleCustom, GameBarPosition, DeviceVibrationMode, NativeMkbMode, UiLayout, UiSection, StreamPlayerType, StreamVideoProcessing, VideoRatio, StreamStat, VideoPosition } from "@/enums/pref-values"; import { CodecProfile, StreamResolution, TouchControllerMode, TouchControllerStyleStandard, TouchControllerStyleCustom, GameBarPosition, DeviceVibrationMode, NativeMkbMode, UiLayout, UiSection, StreamPlayerType, StreamVideoProcessing, VideoRatio, StreamStat, VideoPosition, BlockFeature } from "@/enums/pref-values";
import { MkbMappingDefaultPresetId } from "../local-db/mkb-mapping-presets-table"; import { MkbMappingDefaultPresetId } from "../local-db/mkb-mapping-presets-table";
import { KeyboardShortcutDefaultId } from "../local-db/keyboard-shortcuts-table"; import { KeyboardShortcutDefaultId } from "../local-db/keyboard-shortcuts-table";
import { GhPagesUtils } from "../gh-pages"; import { GhPagesUtils } from "../gh-pages";
@ -586,25 +586,29 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
}, },
}, },
[PrefKey.BYOG_DISABLED]: {
label: t('disable-byog-feature'),
default: false,
},
[PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME]: { [PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME]: {
requiredVariants: 'full', requiredVariants: 'full',
label: t('show-wait-time-in-game-card'), label: t('show-wait-time-in-game-card'),
default: true, default: true,
}, },
[PrefKey.BLOCK_SOCIAL_FEATURES]: {
label: t('disable-social-features'),
default: false,
},
[PrefKey.BLOCK_TRACKING]: { [PrefKey.BLOCK_TRACKING]: {
label: t('disable-xcloud-analytics'), label: t('disable-xcloud-analytics'),
default: false, default: false,
}, },
[PrefKey.BLOCK_FEATURES]: {
label: t('disable-features'),
default: [],
multipleOptions: {
[BlockFeature.CHAT]: t('chat'),
[BlockFeature.FRIENDS]: t('friends-followers'),
[BlockFeature.BYOG]: t('byog'),
// [BlockFeature.NOTIFICATIONS_INVITES]: ut('Notifications: Invites'),
// [BlockFeature.NOTIFICATIONS_ACHIEVEMENTS]: ut('Notifications: Achievements'),
},
},
[PrefKey.USER_AGENT_PROFILE]: { [PrefKey.USER_AGENT_PROFILE]: {
label: t('user-agent-profile'), label: t('user-agent-profile'),
note: '⚠️ ' + t('unexpected-behavior'), note: '⚠️ ' + t('unexpected-behavior'),

View File

@ -27,6 +27,10 @@ export const SUPPORTED_LANGUAGES = {
}; };
const Texts = { const Texts = {
"chat": "Chat",
"friends-followers": "Friends and followers",
"byog": "Stream your own game",
"disable-features": "Disable features",
"activate": "Activate", "activate": "Activate",
"activated": "Activated", "activated": "Activated",
"active": "Active", "active": "Active",