From f8b8012f5c24f9d5ec0171ca50b8bb577663dfc9 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:21:20 +0700 Subject: [PATCH] Add "ignoreNewsSection" patch --- dist/better-xcloud.user.js | 6 ++++++ src/modules/patcher/patcher.ts | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/dist/better-xcloud.user.js b/dist/better-xcloud.user.js index f6f2bb8..efd9a7a 100755 --- a/dist/better-xcloud.user.js +++ b/dist/better-xcloud.user.js @@ -4525,6 +4525,11 @@ true` + text; if (index = str.indexOf(`const ${funcName}=e=>{`), index > -1 && (index = str.indexOf("return ", index)), index > -1 && (index = str.indexOf("?", index)), index < 0) return !1; return str = str.substring(0, index) + "|| true" + str.substring(index), str; }, + ignoreNewsSection(str) { + let index = str.indexOf('Logger("CarouselRow")'); + if (index > -1 && (index = PatcherUtils.lastIndexOf(str, "const ", index, 200)), index < 0) return !1; + return str = PatcherUtils.insertAt(str, index, "return null;"), str; + }, ignorePlayWithFriendsSection(str) { let index = str.indexOf('location:"PlayWithFriendsRow",'); if (index < 0) return !1; @@ -4705,6 +4710,7 @@ ${subsVar} = subs; "changeNotificationsSubscription" ] : [] ]), hideSections = getPref("ui.hideSections"), HOME_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([ + hideSections.includes("news") && "ignoreNewsSection", hideSections.includes("friends") && "ignorePlayWithFriendsSection", hideSections.includes("all-games") && "ignoreAllGamesSection", STATES.browser.capabilities.touch && hideSections.includes("touch") && "ignorePlayWithTouchSection", diff --git a/src/modules/patcher/patcher.ts b/src/modules/patcher/patcher.ts index b1f37c9..3253208 100755 --- a/src/modules/patcher/patcher.ts +++ b/src/modules/patcher/patcher.ts @@ -694,6 +694,18 @@ true` + text; return str; }, + // Don't render News section + ignoreNewsSection(str: string) { + let index = str.indexOf('Logger("CarouselRow")'); + index > -1 && (index = PatcherUtils.lastIndexOf(str, 'const ', index, 200)); + if (index < 0) { + return false; + } + + str = PatcherUtils.insertAt(str, index, 'return null;'); + return str; + }, + // Don't render "Play With Friends" sections ignorePlayWithFriendsSection(str: string) { let index = str.indexOf('location:"PlayWithFriendsRow",'); @@ -1045,6 +1057,7 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([ const hideSections = getPref(PrefKey.UI_HIDE_SECTIONS); let HOME_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([ + hideSections.includes(UiSection.NEWS) && 'ignoreNewsSection', hideSections.includes(UiSection.FRIENDS) && 'ignorePlayWithFriendsSection', hideSections.includes(UiSection.ALL_GAMES) && 'ignoreAllGamesSection', STATES.browser.capabilities.touch && hideSections.includes(UiSection.TOUCH) && 'ignorePlayWithTouchSection',