Compare commits

...

4 Commits

Author SHA1 Message Date
redphx
4bf3bd3bb4 Use findAndParseParams() in "gameCardCustomIcons" patch 2025-05-31 11:30:21 +07:00
redphx
cc33e27bd6 Fix "ignoreSiglSections" patch 2025-05-31 11:16:34 +07:00
redphx
9112853dfc
Update stale.yaml 2025-05-31 09:59:55 +07:00
redphx
368164b567
Create stale.yaml 2025-05-31 09:58:13 +07:00
5 changed files with 120 additions and 36 deletions

25
.github/workflows/stale.yaml vendored Normal file
View File

@ -0,0 +1,25 @@
name: 'Mark stale bug issues'
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight UTC
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: |
This issue has been marked `stale` due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days.
close-issue-message: |
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
days-before-stale: 60
days-before-close: 30
stale-issue-label: 'stale'
only-issues: true
only-labels: 'bug'

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @name Better xCloud
// @namespace https://github.com/redphx
// @version 6.6.1
// @version 6.6.2-beta
// @description Improve Xbox Cloud Gaming (xCloud) experience
// @author redphx
// @license MIT
@ -193,7 +193,7 @@ class UserAgent {
});
}
}
var SCRIPT_VERSION = "6.6.1", SCRIPT_VARIANT = "full", AppInterface = window.AppInterface;
var SCRIPT_VERSION = "6.6.2-beta", SCRIPT_VARIANT = "full", AppInterface = window.AppInterface;
UserAgent.init();
var userAgent = window.navigator.userAgent.toLowerCase(), isTv = userAgent.includes("smart-tv") || userAgent.includes("smarttv") || /\baft.*\b/.test(userAgent), isVr = window.navigator.userAgent.includes("VR") && window.navigator.userAgent.includes("OculusBrowser"), browserHasTouchSupport = "ontouchstart" in window || navigator.maxTouchPoints > 0, userAgentHasTouchSupport = !isTv && !isVr && browserHasTouchSupport, STATES = {
supportedRegion: !0,
@ -5160,6 +5160,30 @@ class PatcherUtils {
let newCode = `window.BX_EXPOSED.reactUseEffect(() => window.BxEventBus.${group}.emit('${eventName}', {}), [])${separator}`;
return str = PatcherUtils.insertAt(str, index, newCode), str;
}
static findAndParseParams(str, index, maxRange) {
let substr = str.substring(index, index + maxRange), startIndex = substr.indexOf("({");
if (startIndex < 0) return !1;
startIndex += 1;
let endIndex = substr.indexOf("})", startIndex);
if (endIndex < 0) return !1;
endIndex += 1;
try {
let input = substr.substring(startIndex, endIndex);
return PatcherUtils.parseObjectVariables(input);
} catch {
return null;
}
}
static parseObjectVariables(input) {
try {
let pairs = [...input.matchAll(/(\w+)\s*:\s*([a-zA-Z_$][\w$]*)/g)], result = {};
for (let [_, key, value] of pairs)
result[key] = value;
return result;
} catch {
return null;
}
}
}
var LOG_TAG2 = "Patcher", PATCHES = {
disableAiTrack(str) {
@ -5346,6 +5370,7 @@ if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFak
let index = str.indexOf("({onCollapse:");
if (index < 0) return !1;
try {
if (!PatcherUtils.findAndParseParams(str, index, 1000)) return !1;
let canShowTakHUDVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, "canShowTakHUD", index, 500, !0) + 1), guideUIVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, "guideUI", index, 500, !0) + 1), onShowStreamMenuVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, "onShowStreamMenu", index, 500, !0) + 1), offsetVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, "offset", index, 500, !0) + 1), newCode = renderString(stream_hud_default, {
guideUI: guideUIVar,
onShowStreamMenu: onShowStreamMenuVar,
@ -5506,8 +5531,9 @@ true` + text;
},
ignoreSiglSections(str) {
let index = str.indexOf("SiglRow-module__heroCard___");
if (index < 0) return !1;
if (index = PatcherUtils.lastIndexOf(str, "const[", index, 300), index < 0) return !1;
if (index >= 0 && (index = PatcherUtils.lastIndexOf(str, "const[", index, 300)), index < 0) return !1;
let params = PatcherUtils.findAndParseParams(str, index - 500, 500);
if (!params || !params.id) return !1;
let PREF_HIDE_SECTIONS = getGlobalPref("ui.hideSections"), siglIds = [], sections = {
"native-mkb": "8fa264dd-124f-4af3-97e8-596fcdf4b486",
"most-popular": "e7590b22-e299-44db-ae22-25c61405454c",
@ -5518,14 +5544,7 @@ true` + text;
let galleryId = sections[section];
galleryId && siglIds.push(galleryId);
}
let newCode = `
if (e && e.id) {
const siglId = e.id;
if (${siglIds.map((item2) => `siglId === "${item2}"`).join(" || ")}) {
return null;
}
}
`;
let checkSyntax = siglIds.map((item2) => `${params.id} === "${item2}"`).join(" || "), newCode = `if (${params.id} && (${checkSyntax})) return null;`;
return str = PatcherUtils.insertAt(str, index, newCode), str;
},
ignoreGenresSection(str) {
@ -5632,8 +5651,10 @@ ${subsVar} = subs;
if (returnIndex < 0) return !1;
let productIdIndex = PatcherUtils.lastIndexOf(str, ",productId:", initialIndex, 300);
if (productIdIndex < 0) return !1;
let productIdVar = PatcherUtils.getVariableNameAfter(str, productIdIndex + 11), supportedInputIconsVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, "supportedInputIcons:", initialIndex, 100, !0));
if (!productIdVar || !supportedInputIconsVar) return !1;
let params = PatcherUtils.findAndParseParams(str, productIdIndex - 200, 400);
if (!params || !params.productId) return !1;
let productIdVar = params.productId, supportedInputIconsVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, "supportedInputIcons:", initialIndex, 100, !0));
if (!supportedInputIconsVar) return !1;
let newCode = renderString(game_card_icons_default, {
productId: productIdVar,
supportedInputIcons: supportedInputIconsVar

File diff suppressed because one or more lines are too long

View File

@ -110,4 +110,41 @@ export class PatcherUtils {
return str;
}
static findAndParseParams(str: string, index: number, maxRange: number) {
const substr = str.substring(index, index + maxRange);
let startIndex = substr.indexOf('({');
if (startIndex < 0) {
return false;
}
startIndex += 1;
let endIndex = substr.indexOf('})', startIndex);
if (endIndex < 0) {
return false;
}
endIndex += 1;
try {
const input = substr.substring(startIndex, endIndex);
return PatcherUtils.parseObjectVariables(input);
} catch {
return null;
}
}
static parseObjectVariables(input: string) {
try {
const pairs = [...input.matchAll(/(\w+)\s*:\s*([a-zA-Z_$][\w$]*)/g)];
const result: Record<string, string> = {};
for (const [_, key, value] of pairs) {
result[key] = value;
}
return result;
} catch {
return null;
}
}
}

View File

@ -399,6 +399,11 @@ if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFak
}
try {
const params = PatcherUtils.findAndParseParams(str, index, 1000);
if (!params) {
return false;
}
const canShowTakHUDVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, 'canShowTakHUD', index, 500, true) + 1);
const guideUIVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, 'guideUI', index, 500, true) + 1);
const onShowStreamMenuVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, 'onShowStreamMenu', index, 500, true) + 1);
@ -768,12 +773,13 @@ true` + text;
// home-page.js
ignoreSiglSections(str: string) {
let index = str.indexOf('SiglRow-module__heroCard___');
index >= 0 && (index = PatcherUtils.lastIndexOf(str, 'const[', index, 300));
if (index < 0) {
return false;
}
index = PatcherUtils.lastIndexOf(str, 'const[', index, 300);
if (index < 0) {
const params = PatcherUtils.findAndParseParams(str, index - 500, 500);
if (!params || !params.id) {
return false;
}
@ -792,16 +798,9 @@ true` + text;
galleryId && siglIds.push(galleryId);
};
const checkSyntax = siglIds.map(item => `siglId === "${item}"`).join(' || ');
const checkSyntax = siglIds.map(item => `${params.id} === "${item}"`).join(' || ');
const newCode = `if (${params.id} && (${checkSyntax})) return null;`;
const newCode = `
if (e && e.id) {
const siglId = e.id;
if (${checkSyntax}) {
return null;
}
}
`;
str = PatcherUtils.insertAt(str, index, newCode);
return str;
},
@ -1031,12 +1030,16 @@ ${subsVar} = subs;
return false;
}
const productIdVar = PatcherUtils.getVariableNameAfter(str, productIdIndex + 11);
const params = PatcherUtils.findAndParseParams(str, productIdIndex - 200, 400);
if (!params || !params.productId) {
return false;
}
const productIdVar = params.productId;
// Find supportedInputIcons and title var names
const supportedInputIconsVar = PatcherUtils.getVariableNameAfter(str, PatcherUtils.indexOf(str, 'supportedInputIcons:', initialIndex, 100, true));
if (!productIdVar || !supportedInputIconsVar) {
if (!supportedInputIconsVar) {
return false;
}