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

@@ -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;
}