mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-25 08:53:04 +02:00
Allow hiding "Recently added, "Leaving soon" and "Genres" sections (#658)
This commit is contained in:
parent
fd665b6fcd
commit
7894dea5ff
24
dist/better-xcloud.pretty.user.js
vendored
24
dist/better-xcloud.pretty.user.js
vendored
@ -399,6 +399,9 @@ var SUPPORTED_LANGUAGES = {
|
|||||||
"zh-TW": "中文(繁體)"
|
"zh-TW": "中文(繁體)"
|
||||||
}, Texts = {
|
}, Texts = {
|
||||||
webgpu: "WebGPU",
|
webgpu: "WebGPU",
|
||||||
|
"section-recently-added": "Recently added",
|
||||||
|
"section-leaving-soon": "Leaving soon",
|
||||||
|
"section-genres": "Genres",
|
||||||
achievements: "Achievements",
|
achievements: "Achievements",
|
||||||
activate: "Activate",
|
activate: "Activate",
|
||||||
activated: "Activated",
|
activated: "Activated",
|
||||||
@ -1647,6 +1650,9 @@ class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
"native-mkb": t("section-native-mkb"),
|
"native-mkb": t("section-native-mkb"),
|
||||||
touch: t("section-touch"),
|
touch: t("section-touch"),
|
||||||
"most-popular": t("section-most-popular"),
|
"most-popular": t("section-most-popular"),
|
||||||
|
"recently-added": t("section-recently-added"),
|
||||||
|
"leaving-soon": t("section-leaving-soon"),
|
||||||
|
genres: t("section-genres"),
|
||||||
"all-games": t("section-all-games")
|
"all-games": t("section-all-games")
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
@ -2785,9 +2791,12 @@ function clearAllData() {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
alert(t("clear-data-success"));
|
alert(t("clear-data-success"));
|
||||||
}
|
}
|
||||||
|
function containsAll(arr, values) {
|
||||||
|
return values.every((val) => arr.includes(val));
|
||||||
|
}
|
||||||
function blockAllNotifications() {
|
function blockAllNotifications() {
|
||||||
let blockFeatures = getGlobalPref("block.features");
|
let blockFeatures = getGlobalPref("block.features");
|
||||||
return ["friends", "notifications-achievements", "notifications-invites"].every((value) => blockFeatures.includes(value));
|
return containsAll(blockFeatures, ["friends", "notifications-achievements", "notifications-invites"]);
|
||||||
}
|
}
|
||||||
function blockSomeNotifications() {
|
function blockSomeNotifications() {
|
||||||
let blockFeatures = getGlobalPref("block.features");
|
let blockFeatures = getGlobalPref("block.features");
|
||||||
@ -5535,7 +5544,9 @@ true` + text;
|
|||||||
if (index = PatcherUtils.lastIndexOf(str, "const[", index, 300), index < 0) return !1;
|
if (index = PatcherUtils.lastIndexOf(str, "const[", index, 300), index < 0) return !1;
|
||||||
let PREF_HIDE_SECTIONS = getGlobalPref("ui.hideSections"), siglIds = [], sections = {
|
let PREF_HIDE_SECTIONS = getGlobalPref("ui.hideSections"), siglIds = [], sections = {
|
||||||
"native-mkb": "8fa264dd-124f-4af3-97e8-596fcdf4b486",
|
"native-mkb": "8fa264dd-124f-4af3-97e8-596fcdf4b486",
|
||||||
"most-popular": "e7590b22-e299-44db-ae22-25c61405454c"
|
"most-popular": "e7590b22-e299-44db-ae22-25c61405454c",
|
||||||
|
"leaving-soon": "393f05bf-e596-4ef6-9487-6d4fa0eab987",
|
||||||
|
"recently-added": "44a55037-770f-4bbf-bde5-a9fa27dba1da"
|
||||||
};
|
};
|
||||||
for (let section of PREF_HIDE_SECTIONS) {
|
for (let section of PREF_HIDE_SECTIONS) {
|
||||||
let galleryId = sections[section];
|
let galleryId = sections[section];
|
||||||
@ -5551,6 +5562,11 @@ if (e && e.id) {
|
|||||||
`;
|
`;
|
||||||
return str = PatcherUtils.insertAt(str, index, newCode), str;
|
return str = PatcherUtils.insertAt(str, index, newCode), str;
|
||||||
},
|
},
|
||||||
|
ignoreGenresSection(str) {
|
||||||
|
let index = str.indexOf('="GenresRow"');
|
||||||
|
if (index > -1 && (index = PatcherUtils.lastIndexOf(str, "{", index)), index < 0) return !1;
|
||||||
|
return str = PatcherUtils.insertAt(str, index + 1, "return null;"), str;
|
||||||
|
},
|
||||||
overrideStorageGetSettings(str) {
|
overrideStorageGetSettings(str) {
|
||||||
let text = "}getSetting(e){";
|
let text = "}getSetting(e){";
|
||||||
if (!str.includes(text)) return !1;
|
if (!str.includes(text)) return !1;
|
||||||
@ -5729,6 +5745,7 @@ ${subsVar} = subs;
|
|||||||
hideSections.includes("news") && "ignoreNewsSection",
|
hideSections.includes("news") && "ignoreNewsSection",
|
||||||
hideSections.includes("friends") && "ignorePlayWithFriendsSection",
|
hideSections.includes("friends") && "ignorePlayWithFriendsSection",
|
||||||
hideSections.includes("all-games") && "ignoreAllGamesSection",
|
hideSections.includes("all-games") && "ignoreAllGamesSection",
|
||||||
|
hideSections.includes("genres") && "ignoreGenresSection",
|
||||||
STATES.browser.capabilities.touch && hideSections.includes("touch") && "ignorePlayWithTouchSection",
|
STATES.browser.capabilities.touch && hideSections.includes("touch") && "ignorePlayWithTouchSection",
|
||||||
hideSections.some((value) => ["native-mkb", "most-popular"].includes(value)) && "ignoreSiglSections",
|
hideSections.some((value) => ["native-mkb", "most-popular"].includes(value)) && "ignoreSiglSections",
|
||||||
...getGlobalPref("ui.imageQuality") < 90 ? [
|
...getGlobalPref("ui.imageQuality") < 90 ? [
|
||||||
@ -9290,6 +9307,9 @@ function addCss() {
|
|||||||
if (PREF_HIDE_SECTIONS.includes("all-games")) selectorToHide.push("#BodyContent div[class*=AllGamesRow-module__gridContainer]"), selectorToHide.push("#BodyContent div[class*=AllGamesRow-module__rowHeader]");
|
if (PREF_HIDE_SECTIONS.includes("all-games")) selectorToHide.push("#BodyContent div[class*=AllGamesRow-module__gridContainer]"), selectorToHide.push("#BodyContent div[class*=AllGamesRow-module__rowHeader]");
|
||||||
if (PREF_HIDE_SECTIONS.includes("most-popular")) selectorToHide.push('#BodyContent div[class*=HomePage-module__bottomSpacing]:has(a[href="/play/gallery/popular"])');
|
if (PREF_HIDE_SECTIONS.includes("most-popular")) selectorToHide.push('#BodyContent div[class*=HomePage-module__bottomSpacing]:has(a[href="/play/gallery/popular"])');
|
||||||
if (PREF_HIDE_SECTIONS.includes("touch")) selectorToHide.push('#BodyContent div[class*=HomePage-module__bottomSpacing]:has(a[href="/play/gallery/touch"])');
|
if (PREF_HIDE_SECTIONS.includes("touch")) selectorToHide.push('#BodyContent div[class*=HomePage-module__bottomSpacing]:has(a[href="/play/gallery/touch"])');
|
||||||
|
if (PREF_HIDE_SECTIONS.includes("recently-added")) selectorToHide.push('#BodyContent div[class*=HomePage-module__bottomSpacing]:has(a[href="/play/gallery/recently-added"])');
|
||||||
|
if (PREF_HIDE_SECTIONS.includes("genres")) selectorToHide.push("#BodyContent div[class*=HomePage-module__genresRow]");
|
||||||
|
if (containsAll(PREF_HIDE_SECTIONS, ["recently-added", "leaving-soon", "genres", "all-games"])) selectorToHide.push("#BodyContent div[class*=GamePassPromoSection-module__container]");
|
||||||
if (getGlobalPref("block.features").includes("friends")) selectorToHide.push("#gamepass-dialog-root div[class^=AchievementsPreview-module__container] + button[class*=HomeLandingPage-module__button]");
|
if (getGlobalPref("block.features").includes("friends")) selectorToHide.push("#gamepass-dialog-root div[class^=AchievementsPreview-module__container] + button[class*=HomeLandingPage-module__button]");
|
||||||
if (selectorToHide) css += selectorToHide.join(",") + "{ display: none; }";
|
if (selectorToHide) css += selectorToHide.join(",") + "{ display: none; }";
|
||||||
if (getGlobalPref("ui.reduceAnimations")) css += "div[class*=GameCard-module__gameTitleInnerWrapper],div[class*=GameCard-module__card],div[class*=ScrollArrows-module]{transition:none !important}";
|
if (getGlobalPref("ui.reduceAnimations")) css += "div[class*=GameCard-module__gameTitleInnerWrapper],div[class*=GameCard-module__card],div[class*=ScrollArrows-module]{transition:none !important}";
|
||||||
|
15
dist/better-xcloud.user.js
vendored
15
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -1,7 +1,9 @@
|
|||||||
export enum GamePassCloudGallery {
|
export enum GamePassCloudGallery {
|
||||||
ALL = '29a81209-df6f-41fd-a528-2ae6b91f719c',
|
ALL = '29a81209-df6f-41fd-a528-2ae6b91f719c',
|
||||||
ALL_WITH_BYGO = 'ce573635-7c18-4d0c-9d68-90b932393470',
|
ALL_WITH_BYGO = 'ce573635-7c18-4d0c-9d68-90b932393470',
|
||||||
|
LEAVING_SOON = '393f05bf-e596-4ef6-9487-6d4fa0eab987',
|
||||||
MOST_POPULAR = 'e7590b22-e299-44db-ae22-25c61405454c',
|
MOST_POPULAR = 'e7590b22-e299-44db-ae22-25c61405454c',
|
||||||
NATIVE_MKB = '8fa264dd-124f-4af3-97e8-596fcdf4b486',
|
NATIVE_MKB = '8fa264dd-124f-4af3-97e8-596fcdf4b486',
|
||||||
|
RECENTLY_ADDED = '44a55037-770f-4bbf-bde5-a9fa27dba1da',
|
||||||
TOUCH = '9c86f07a-f3e8-45ad-82a0-a1f759597059',
|
TOUCH = '9c86f07a-f3e8-45ad-82a0-a1f759597059',
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ export const enum UiSection {
|
|||||||
NEWS = 'news',
|
NEWS = 'news',
|
||||||
TOUCH = 'touch',
|
TOUCH = 'touch',
|
||||||
BOYG = 'byog',
|
BOYG = 'byog',
|
||||||
|
RECENTLY_ADDED = 'recently-added',
|
||||||
|
LEAVING_SOON = 'leaving-soon',
|
||||||
|
GENRES = 'genres',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum GameBarPosition {
|
export const enum GameBarPosition {
|
||||||
|
@ -796,6 +796,8 @@ true` + text;
|
|||||||
const sections: PartialRecord<UiSection, GamePassCloudGallery> = {
|
const sections: PartialRecord<UiSection, GamePassCloudGallery> = {
|
||||||
[UiSection.NATIVE_MKB]: GamePassCloudGallery.NATIVE_MKB,
|
[UiSection.NATIVE_MKB]: GamePassCloudGallery.NATIVE_MKB,
|
||||||
[UiSection.MOST_POPULAR]: GamePassCloudGallery.MOST_POPULAR,
|
[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) {
|
for (const section of PREF_HIDE_SECTIONS) {
|
||||||
@ -817,6 +819,17 @@ if (e && e.id) {
|
|||||||
return str;
|
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()
|
// Override Storage.getSettings()
|
||||||
overrideStorageGetSettings(str: string) {
|
overrideStorageGetSettings(str: string) {
|
||||||
let text = '}getSetting(e){';
|
let text = '}getSetting(e){';
|
||||||
@ -1193,6 +1206,7 @@ let HOME_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
|||||||
hideSections.includes(UiSection.NEWS) && 'ignoreNewsSection',
|
hideSections.includes(UiSection.NEWS) && 'ignoreNewsSection',
|
||||||
hideSections.includes(UiSection.FRIENDS) && 'ignorePlayWithFriendsSection',
|
hideSections.includes(UiSection.FRIENDS) && 'ignorePlayWithFriendsSection',
|
||||||
hideSections.includes(UiSection.ALL_GAMES) && 'ignoreAllGamesSection',
|
hideSections.includes(UiSection.ALL_GAMES) && 'ignoreAllGamesSection',
|
||||||
|
hideSections.includes(UiSection.GENRES) && 'ignoreGenresSection',
|
||||||
STATES.browser.capabilities.touch && hideSections.includes(UiSection.TOUCH) && 'ignorePlayWithTouchSection',
|
STATES.browser.capabilities.touch && hideSections.includes(UiSection.TOUCH) && 'ignorePlayWithTouchSection',
|
||||||
hideSections.some(value => [UiSection.NATIVE_MKB, UiSection.MOST_POPULAR].includes(value)) && 'ignoreSiglSections',
|
hideSections.some(value => [UiSection.NATIVE_MKB, UiSection.MOST_POPULAR].includes(value)) && 'ignoreSiglSections',
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import { compressCss, isLiteVersion, renderStylus } from "@macros/build" with {
|
|||||||
import { BlockFeature, UiSection } from "@/enums/pref-values";
|
import { BlockFeature, UiSection } from "@/enums/pref-values";
|
||||||
import { GlobalPref } from "@/enums/pref-keys";
|
import { GlobalPref } from "@/enums/pref-keys";
|
||||||
import { getGlobalPref } from "./pref-utils";
|
import { getGlobalPref } from "./pref-utils";
|
||||||
|
import { containsAll } from "./utils";
|
||||||
|
|
||||||
|
|
||||||
export function addCss() {
|
export function addCss() {
|
||||||
@ -44,6 +45,21 @@ export function addCss() {
|
|||||||
selectorToHide.push('#BodyContent div[class*=HomePage-module__bottomSpacing]:has(a[href="/play/gallery/touch"])');
|
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
|
// Hide "Start a party" button in the Guide menu
|
||||||
if (getGlobalPref(GlobalPref.BLOCK_FEATURES).includes(BlockFeature.FRIENDS)) {
|
if (getGlobalPref(GlobalPref.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]');
|
||||||
|
@ -457,8 +457,10 @@ export class GlobalSettingsStorage extends BaseSettingsStorage<GlobalPref> {
|
|||||||
[UiSection.FRIENDS]: t('section-play-with-friends'),
|
[UiSection.FRIENDS]: t('section-play-with-friends'),
|
||||||
[UiSection.NATIVE_MKB]: t('section-native-mkb'),
|
[UiSection.NATIVE_MKB]: t('section-native-mkb'),
|
||||||
[UiSection.TOUCH]: t('section-touch'),
|
[UiSection.TOUCH]: t('section-touch'),
|
||||||
// [UiSection.BOYG]: t('section-byog'),
|
|
||||||
[UiSection.MOST_POPULAR]: t('section-most-popular'),
|
[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'),
|
[UiSection.ALL_GAMES]: t('section-all-games'),
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
|
@ -28,6 +28,9 @@ export const SUPPORTED_LANGUAGES = {
|
|||||||
|
|
||||||
const Texts = {
|
const Texts = {
|
||||||
"webgpu": "WebGPU",
|
"webgpu": "WebGPU",
|
||||||
|
"section-recently-added": "Recently added",
|
||||||
|
"section-leaving-soon": "Leaving soon",
|
||||||
|
"section-genres": "Genres",
|
||||||
"achievements": "Achievements",
|
"achievements": "Achievements",
|
||||||
"activate": "Activate",
|
"activate": "Activate",
|
||||||
"activated": "Activated",
|
"activated": "Activated",
|
||||||
|
@ -154,9 +154,13 @@ export function clearAllData() {
|
|||||||
alert(t('clear-data-success'));
|
alert(t('clear-data-success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function containsAll(arr: Array<any>, values: Array<any>) {
|
||||||
|
return values.every(val => arr.includes(val));
|
||||||
|
}
|
||||||
|
|
||||||
export function blockAllNotifications() {
|
export function blockAllNotifications() {
|
||||||
const blockFeatures = getGlobalPref(GlobalPref.BLOCK_FEATURES);
|
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;
|
return blockAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user