Allow hiding "Recently added, "Leaving soon" and "Genres" sections (#658)

This commit is contained in:
redphx
2025-02-03 21:25:38 +07:00
parent fd665b6fcd
commit 7894dea5ff
9 changed files with 76 additions and 11 deletions

View File

@@ -1,7 +1,9 @@
export enum GamePassCloudGallery {
ALL = '29a81209-df6f-41fd-a528-2ae6b91f719c',
ALL_WITH_BYGO = 'ce573635-7c18-4d0c-9d68-90b932393470',
LEAVING_SOON = '393f05bf-e596-4ef6-9487-6d4fa0eab987',
MOST_POPULAR = 'e7590b22-e299-44db-ae22-25c61405454c',
NATIVE_MKB = '8fa264dd-124f-4af3-97e8-596fcdf4b486',
RECENTLY_ADDED = '44a55037-770f-4bbf-bde5-a9fa27dba1da',
TOUCH = '9c86f07a-f3e8-45ad-82a0-a1f759597059',
}

View File

@@ -6,6 +6,9 @@ export const enum UiSection {
NEWS = 'news',
TOUCH = 'touch',
BOYG = 'byog',
RECENTLY_ADDED = 'recently-added',
LEAVING_SOON = 'leaving-soon',
GENRES = 'genres',
}
export const enum GameBarPosition {

View File

@@ -796,6 +796,8 @@ true` + text;
const sections: PartialRecord<UiSection, GamePassCloudGallery> = {
[UiSection.NATIVE_MKB]: GamePassCloudGallery.NATIVE_MKB,
[UiSection.MOST_POPULAR]: GamePassCloudGallery.MOST_POPULAR,
[UiSection.LEAVING_SOON]: GamePassCloudGallery.LEAVING_SOON,
[UiSection.RECENTLY_ADDED]: GamePassCloudGallery.RECENTLY_ADDED,
};
for (const section of PREF_HIDE_SECTIONS) {
@@ -817,6 +819,17 @@ if (e && e.id) {
return str;
},
ignoreGenresSection(str: string) {
let index = str.indexOf('="GenresRow"');
index > -1 && (index = PatcherUtils.lastIndexOf(str, '{', index));
if (index < 0) {
return false;
}
str = PatcherUtils.insertAt(str, index + 1, 'return null;');
return str;
},
// Override Storage.getSettings()
overrideStorageGetSettings(str: string) {
let text = '}getSetting(e){';
@@ -1193,6 +1206,7 @@ let HOME_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
hideSections.includes(UiSection.NEWS) && 'ignoreNewsSection',
hideSections.includes(UiSection.FRIENDS) && 'ignorePlayWithFriendsSection',
hideSections.includes(UiSection.ALL_GAMES) && 'ignoreAllGamesSection',
hideSections.includes(UiSection.GENRES) && 'ignoreGenresSection',
STATES.browser.capabilities.touch && hideSections.includes(UiSection.TOUCH) && 'ignorePlayWithTouchSection',
hideSections.some(value => [UiSection.NATIVE_MKB, UiSection.MOST_POPULAR].includes(value)) && 'ignoreSiglSections',

View File

@@ -3,6 +3,7 @@ import { compressCss, isLiteVersion, renderStylus } from "@macros/build" with {
import { BlockFeature, UiSection } from "@/enums/pref-values";
import { GlobalPref } from "@/enums/pref-keys";
import { getGlobalPref } from "./pref-utils";
import { containsAll } from "./utils";
export function addCss() {
@@ -44,6 +45,21 @@ export function addCss() {
selectorToHide.push('#BodyContent div[class*=HomePage-module__bottomSpacing]:has(a[href="/play/gallery/touch"])');
}
// Hide "Recently added" section
if (PREF_HIDE_SECTIONS.includes(UiSection.RECENTLY_ADDED)) {
selectorToHide.push('#BodyContent div[class*=HomePage-module__bottomSpacing]:has(a[href="/play/gallery/recently-added"])');
}
// Hide "Genres section"
if (PREF_HIDE_SECTIONS.includes(UiSection.GENRES)) {
selectorToHide.push('#BodyContent div[class*=HomePage-module__genresRow]');
}
// Hide "GamePassPromo"
if (containsAll(PREF_HIDE_SECTIONS, [UiSection.RECENTLY_ADDED, UiSection.LEAVING_SOON, UiSection.GENRES, UiSection.ALL_GAMES])) {
selectorToHide.push('#BodyContent div[class*=GamePassPromoSection-module__container]');
}
// Hide "Start a party" button in the Guide menu
if (getGlobalPref(GlobalPref.BLOCK_FEATURES).includes(BlockFeature.FRIENDS)) {
selectorToHide.push('#gamepass-dialog-root div[class^=AchievementsPreview-module__container] + button[class*=HomeLandingPage-module__button]');

View File

@@ -457,8 +457,10 @@ export class GlobalSettingsStorage extends BaseSettingsStorage<GlobalPref> {
[UiSection.FRIENDS]: t('section-play-with-friends'),
[UiSection.NATIVE_MKB]: t('section-native-mkb'),
[UiSection.TOUCH]: t('section-touch'),
// [UiSection.BOYG]: t('section-byog'),
[UiSection.MOST_POPULAR]: t('section-most-popular'),
[UiSection.RECENTLY_ADDED]: t('section-recently-added'),
[UiSection.LEAVING_SOON]: t('section-leaving-soon'),
[UiSection.GENRES]: t('section-genres'),
[UiSection.ALL_GAMES]: t('section-all-games'),
},
params: {

View File

@@ -28,6 +28,9 @@ export const SUPPORTED_LANGUAGES = {
const Texts = {
"webgpu": "WebGPU",
"section-recently-added": "Recently added",
"section-leaving-soon": "Leaving soon",
"section-genres": "Genres",
"achievements": "Achievements",
"activate": "Activate",
"activated": "Activated",

View File

@@ -154,9 +154,13 @@ export function clearAllData() {
alert(t('clear-data-success'));
}
export function containsAll(arr: Array<any>, values: Array<any>) {
return values.every(val => arr.includes(val));
}
export function blockAllNotifications() {
const blockFeatures = getGlobalPref(GlobalPref.BLOCK_FEATURES);
const blockAll = [BlockFeature.FRIENDS, BlockFeature.NOTIFICATIONS_ACHIEVEMENTS, BlockFeature.NOTIFICATIONS_INVITES].every(value => blockFeatures.includes(value));
const blockAll = containsAll(blockFeatures, [BlockFeature.FRIENDS, BlockFeature.NOTIFICATIONS_ACHIEVEMENTS, BlockFeature.NOTIFICATIONS_INVITES]);
return blockAll;
}