mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-29 02:41:44 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
b733d55e9e | |||
317ac9017b | |||
b8c62a1f4d | |||
7332528f72 | |||
d063500aae |
2
dist/better-xcloud.meta.js
vendored
2
dist/better-xcloud.meta.js
vendored
@ -1,5 +1,5 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 6.4.6
|
// @version 6.4.7
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
31
dist/better-xcloud.pretty.user.js
vendored
31
dist/better-xcloud.pretty.user.js
vendored
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 6.4.6
|
// @version 6.4.7
|
||||||
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
||||||
// @author redphx
|
// @author redphx
|
||||||
// @license MIT
|
// @license MIT
|
||||||
@ -192,7 +192,7 @@ class UserAgent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var SCRIPT_VERSION = "6.4.6", SCRIPT_VARIANT = "full", AppInterface = window.AppInterface;
|
var SCRIPT_VERSION = "6.4.7", SCRIPT_VARIANT = "full", AppInterface = window.AppInterface;
|
||||||
UserAgent.init();
|
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 = {
|
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,
|
supportedRegion: !0,
|
||||||
@ -5023,6 +5023,9 @@ class TouchController {
|
|||||||
static getCustomList() {
|
static getCustomList() {
|
||||||
return TouchController.#customList;
|
return TouchController.#customList;
|
||||||
}
|
}
|
||||||
|
static hasCustomControl(productId) {
|
||||||
|
return TouchController.#customList?.includes(productId);
|
||||||
|
}
|
||||||
static setup() {
|
static setup() {
|
||||||
window.testTouchLayout = (layout) => {
|
window.testTouchLayout = (layout) => {
|
||||||
let { touchLayoutManager } = window.BX_EXPOSED;
|
let { touchLayoutManager } = window.BX_EXPOSED;
|
||||||
@ -5186,7 +5189,7 @@ remotePlayServerId: (window.BX_REMOTE_PLAY_CONFIG && window.BX_REMOTE_PLAY_CONFI
|
|||||||
remotePlayDisableAchievementToast(str) {
|
remotePlayDisableAchievementToast(str) {
|
||||||
let text = ".AchievementUnlock:{";
|
let text = ".AchievementUnlock:{";
|
||||||
if (!str.includes(text)) return !1;
|
if (!str.includes(text)) return !1;
|
||||||
let newCode = "if (!!window.BX_REMOTE_PLAY_CONFIG) return;";
|
let newCode = "if (window.location.pathname.includes('/consoles/launch/')) return;";
|
||||||
return str.replace(text, text + newCode);
|
return str.replace(text, text + newCode);
|
||||||
},
|
},
|
||||||
blockWebRtcStatsCollector(str) {
|
blockWebRtcStatsCollector(str) {
|
||||||
@ -5654,6 +5657,17 @@ ${subsVar} = subs;
|
|||||||
let index = str.indexOf("GuideAchievementDetail.useParams()");
|
let index = str.indexOf("GuideAchievementDetail.useParams()");
|
||||||
if (index > -1 && (index = PatcherUtils.lastIndexOf(str, "const", index, 200)), index < 0) return !1;
|
if (index > -1 && (index = PatcherUtils.lastIndexOf(str, "const", index, 200)), index < 0) return !1;
|
||||||
return PatcherUtils.injectUseEffect(str, index, "Script", "ui.guideAchievementDetail.rendered");
|
return PatcherUtils.injectUseEffect(str, index, "Script", "ui.guideAchievementDetail.rendered");
|
||||||
|
},
|
||||||
|
patchCustomInputIcon(str) {
|
||||||
|
let index = str.indexOf('.MouseAndKeyboard="MouseAndKeyboard"');
|
||||||
|
if (index < 0) return !1;
|
||||||
|
let productIdMatch = /const (\w+)=(\w+)=>{/.exec(str.substring(index, index + 200));
|
||||||
|
if (!productIdMatch) return !1;
|
||||||
|
str = str.replace(productIdMatch[0], productIdMatch[0] + `const productId = ${productIdMatch[2]};`);
|
||||||
|
let match = /(\w+)&&(\w+\.push\(\w+\.Touch\))/.exec(str);
|
||||||
|
if (!match) return !1;
|
||||||
|
if (str = str.replace(match[0], `(${match[1]} || window.BX_EXPOSED.hasCustomTouchControl(productId)) && ${match[2]}`), match = /(\w+)&&(\w+\.push\(\w+\.MouseAndKeyboard\))/.exec(str), match) str = str.replace(match[0], `(${match[1]} || window.BX_EXPOSED.hasCustomNativeMkb(productId)) && ${match[2]}`);
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
}, PATCH_ORDERS = PatcherUtils.filterPatches([
|
}, PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||||
...AppInterface && getGlobalPref("nativeMkb.mode") === "on" ? [
|
...AppInterface && getGlobalPref("nativeMkb.mode") === "on" ? [
|
||||||
@ -5683,6 +5697,7 @@ ${subsVar} = subs;
|
|||||||
"guideAchievementsDefaultLocked",
|
"guideAchievementsDefaultLocked",
|
||||||
"injectHeaderUseEffect",
|
"injectHeaderUseEffect",
|
||||||
"homePageBeforeLoad",
|
"homePageBeforeLoad",
|
||||||
|
"patchCustomInputIcon",
|
||||||
"gameCardCustomIcons",
|
"gameCardCustomIcons",
|
||||||
"productDetailPageBeforeLoad",
|
"productDetailPageBeforeLoad",
|
||||||
"enableTvRoutes",
|
"enableTvRoutes",
|
||||||
@ -5737,7 +5752,6 @@ ${subsVar} = subs;
|
|||||||
getGlobalPref("touchController.opacity.default") !== 100 && "patchTouchControlDefaultOpacity",
|
getGlobalPref("touchController.opacity.default") !== 100 && "patchTouchControlDefaultOpacity",
|
||||||
getGlobalPref("touchController.mode") !== "off" && (getGlobalPref("mkb.enabled") || getGlobalPref("nativeMkb.mode") === "on") && "patchBabylonRendererClass"
|
getGlobalPref("touchController.mode") !== "off" && (getGlobalPref("mkb.enabled") || getGlobalPref("nativeMkb.mode") === "on") && "patchBabylonRendererClass"
|
||||||
] : [],
|
] : [],
|
||||||
BX_FLAGS.EnableXcloudLogging && "enableConsoleLogging",
|
|
||||||
"patchPollGamepads",
|
"patchPollGamepads",
|
||||||
getGlobalPref("stream.video.combineAudio") && "streamCombineSources",
|
getGlobalPref("stream.video.combineAudio") && "streamCombineSources",
|
||||||
...getGlobalPref("xhome.enabled") ? [
|
...getGlobalPref("xhome.enabled") ? [
|
||||||
@ -5827,11 +5841,12 @@ class PatcherCache {
|
|||||||
PATCH_ORDERS = this.cleanupPatches(PATCH_ORDERS), STREAM_PAGE_PATCH_ORDERS = this.cleanupPatches(STREAM_PAGE_PATCH_ORDERS), PRODUCT_DETAIL_PAGE_PATCH_ORDERS = this.cleanupPatches(PRODUCT_DETAIL_PAGE_PATCH_ORDERS), BxLogger.info(LOG_TAG2, "PATCH_ORDERS", PATCH_ORDERS.slice(0));
|
PATCH_ORDERS = this.cleanupPatches(PATCH_ORDERS), STREAM_PAGE_PATCH_ORDERS = this.cleanupPatches(STREAM_PAGE_PATCH_ORDERS), PRODUCT_DETAIL_PAGE_PATCH_ORDERS = this.cleanupPatches(PRODUCT_DETAIL_PAGE_PATCH_ORDERS), BxLogger.info(LOG_TAG2, "PATCH_ORDERS", PATCH_ORDERS.slice(0));
|
||||||
}
|
}
|
||||||
getSignature() {
|
getSignature() {
|
||||||
let scriptVersion = SCRIPT_VERSION, patches = JSON.stringify(ALL_PATCHES), webVersion = "", $link = document.querySelector('link[data-chunk="client"][href*="/client."]');
|
let scriptVersion = SCRIPT_VERSION, patches = JSON.stringify(ALL_PATCHES), webVersion = "", $link = document.querySelector('link[data-chunk="client"][as="script"][href*="/client."]');
|
||||||
if ($link) {
|
if ($link) {
|
||||||
let match = /\/client\.([^\.]+)\.js/.exec($link.href);
|
let match = /\/client\.([^\.]+)\.js/.exec($link.href);
|
||||||
match && (webVersion = match[1]);
|
match && (webVersion = match[1]);
|
||||||
} else webVersion = document.querySelector("meta[name=gamepass-app-version]")?.content ?? "";
|
}
|
||||||
|
if (!webVersion) webVersion = document.querySelector("meta[name=gamepass-app-version]")?.content ?? "";
|
||||||
return hashCode(scriptVersion + webVersion + patches);
|
return hashCode(scriptVersion + webVersion + patches);
|
||||||
}
|
}
|
||||||
clear() {
|
clear() {
|
||||||
@ -8281,6 +8296,10 @@ var BxExposed = {
|
|||||||
createReactLocalCoOpIcon: (attrs) => {
|
createReactLocalCoOpIcon: (attrs) => {
|
||||||
let reactCE = window.BX_EXPOSED.reactCreateElement;
|
let reactCE = window.BX_EXPOSED.reactCreateElement;
|
||||||
return reactCE("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 32 32", "fill-rule": "evenodd", "stroke-linecap": "round", "stroke-linejoin": "round", ...attrs }, reactCE("g", null, reactCE("path", { d: "M24.272 11.165h-3.294l-3.14 3.564c-.391.391-.922.611-1.476.611a2.1 2.1 0 0 1-2.087-2.088 2.09 2.09 0 0 1 .031-.362l1.22-6.274a3.89 3.89 0 0 1 3.81-3.206h6.57c1.834 0 3.439 1.573 3.833 3.295l1.205 6.185a2.09 2.09 0 0 1 .031.362 2.1 2.1 0 0 1-2.087 2.088c-.554 0-1.085-.22-1.476-.611l-3.14-3.564", fill: "none", stroke: "#fff", "stroke-width": "2" }), reactCE("circle", { cx: "22.625", cy: "5.874", r: ".879" }), reactCE("path", { d: "M11.022 24.415H7.728l-3.14 3.564c-.391.391-.922.611-1.476.611a2.1 2.1 0 0 1-2.087-2.088 2.09 2.09 0 0 1 .031-.362l1.22-6.274a3.89 3.89 0 0 1 3.81-3.206h6.57c1.834 0 3.439 1.573 3.833 3.295l1.205 6.185a2.09 2.09 0 0 1 .031.362 2.1 2.1 0 0 1-2.087 2.088c-.554 0-1.085-.22-1.476-.611l-3.14-3.564", fill: "none", stroke: "#fff", "stroke-width": "2" }), reactCE("circle", { cx: "9.375", cy: "19.124", r: ".879" })));
|
return reactCE("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 32 32", "fill-rule": "evenodd", "stroke-linecap": "round", "stroke-linejoin": "round", ...attrs }, reactCE("g", null, reactCE("path", { d: "M24.272 11.165h-3.294l-3.14 3.564c-.391.391-.922.611-1.476.611a2.1 2.1 0 0 1-2.087-2.088 2.09 2.09 0 0 1 .031-.362l1.22-6.274a3.89 3.89 0 0 1 3.81-3.206h6.57c1.834 0 3.439 1.573 3.833 3.295l1.205 6.185a2.09 2.09 0 0 1 .031.362 2.1 2.1 0 0 1-2.087 2.088c-.554 0-1.085-.22-1.476-.611l-3.14-3.564", fill: "none", stroke: "#fff", "stroke-width": "2" }), reactCE("circle", { cx: "22.625", cy: "5.874", r: ".879" }), reactCE("path", { d: "M11.022 24.415H7.728l-3.14 3.564c-.391.391-.922.611-1.476.611a2.1 2.1 0 0 1-2.087-2.088 2.09 2.09 0 0 1 .031-.362l1.22-6.274a3.89 3.89 0 0 1 3.81-3.206h6.57c1.834 0 3.439 1.573 3.833 3.295l1.205 6.185a2.09 2.09 0 0 1 .031.362 2.1 2.1 0 0 1-2.087 2.088c-.554 0-1.085-.22-1.476-.611l-3.14-3.564", fill: "none", stroke: "#fff", "stroke-width": "2" }), reactCE("circle", { cx: "9.375", cy: "19.124", r: ".879" })));
|
||||||
|
},
|
||||||
|
hasCustomTouchControl: TouchController.hasCustomControl,
|
||||||
|
hasCustomNativeMkb: (productId) => {
|
||||||
|
return BX_FLAGS.ForceNativeMkbTitles?.includes(productId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function localRedirect(path) {
|
function localRedirect(path) {
|
||||||
|
16
dist/better-xcloud.user.js
vendored
16
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -133,7 +133,7 @@ remotePlayServerId: (window.BX_REMOTE_PLAY_CONFIG && window.BX_REMOTE_PLAY_CONFI
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newCode = `if (!!window.BX_REMOTE_PLAY_CONFIG) return;`;
|
const newCode = `if (window.location.pathname.includes('/consoles/launch/')) return;`;
|
||||||
return str.replace(text, text + newCode);
|
return str.replace(text, text + newCode);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1169,6 +1169,36 @@ ${subsVar} = subs;
|
|||||||
return PatcherUtils.injectUseEffect(str, index, 'Script', 'ui.guideAchievementDetail.rendered');
|
return PatcherUtils.injectUseEffect(str, index, 'Script', 'ui.guideAchievementDetail.rendered');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
patchCustomInputIcon(str: string) {
|
||||||
|
let index = str.indexOf('.MouseAndKeyboard="MouseAndKeyboard"');
|
||||||
|
if (index < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get productId
|
||||||
|
const productIdMatch = /const (\w+)=(\w+)=>{/.exec(str.substring(index, index + 200));
|
||||||
|
if (!productIdMatch) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define productId variable
|
||||||
|
str = str.replace(productIdMatch[0], productIdMatch[0] + `const productId = ${productIdMatch[2]};`);
|
||||||
|
|
||||||
|
let match = /(\w+)&&(\w+\.push\(\w+\.Touch\))/.exec(str);
|
||||||
|
if (!match) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = str.replace(match[0], `(${match[1]} || window.BX_EXPOSED.hasCustomTouchControl(productId)) && ${match[2]}`);
|
||||||
|
|
||||||
|
match = /(\w+)&&(\w+\.push\(\w+\.MouseAndKeyboard\))/.exec(str);
|
||||||
|
if (match) {
|
||||||
|
str = str.replace(match[0], `(${match[1]} || window.BX_EXPOSED.hasCustomNativeMkb(productId)) && ${match[2]}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
patchBasicGameInfo(str: string) {
|
patchBasicGameInfo(str: string) {
|
||||||
let index = str.indexOf('.ChildXboxTitleIds,offerings');
|
let index = str.indexOf('.ChildXboxTitleIds,offerings');
|
||||||
@ -1240,6 +1270,8 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
|
|||||||
|
|
||||||
'homePageBeforeLoad',
|
'homePageBeforeLoad',
|
||||||
|
|
||||||
|
'patchCustomInputIcon',
|
||||||
|
|
||||||
'gameCardCustomIcons',
|
'gameCardCustomIcons',
|
||||||
// 'gameCardPassTitle',
|
// 'gameCardPassTitle',
|
||||||
|
|
||||||
@ -1329,8 +1361,6 @@ let STREAM_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
|||||||
(getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) !== TouchControllerMode.OFF && (getGlobalPref(GlobalPref.MKB_ENABLED) || getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.ON)) && 'patchBabylonRendererClass',
|
(getGlobalPref(GlobalPref.TOUCH_CONTROLLER_MODE) !== TouchControllerMode.OFF && (getGlobalPref(GlobalPref.MKB_ENABLED) || getGlobalPref(GlobalPref.NATIVE_MKB_MODE) === NativeMkbMode.ON)) && 'patchBabylonRendererClass',
|
||||||
] : []) as PatchArray,
|
] : []) as PatchArray,
|
||||||
|
|
||||||
BX_FLAGS.EnableXcloudLogging && 'enableConsoleLogging',
|
|
||||||
|
|
||||||
'patchPollGamepads',
|
'patchPollGamepads',
|
||||||
|
|
||||||
getGlobalPref(GlobalPref.STREAM_COMBINE_SOURCES) && 'streamCombineSources',
|
getGlobalPref(GlobalPref.STREAM_COMBINE_SOURCES) && 'streamCombineSources',
|
||||||
@ -1546,11 +1576,13 @@ export class PatcherCache {
|
|||||||
|
|
||||||
// Get client.js's hash
|
// Get client.js's hash
|
||||||
let webVersion = '';
|
let webVersion = '';
|
||||||
const $link = document.querySelector<HTMLLinkElement>('link[data-chunk="client"][href*="/client."]');
|
const $link = document.querySelector<HTMLLinkElement>('link[data-chunk="client"][as="script"][href*="/client."]');
|
||||||
if ($link) {
|
if ($link) {
|
||||||
const match = /\/client\.([^\.]+)\.js/.exec($link.href);
|
const match = /\/client\.([^\.]+)\.js/.exec($link.href);
|
||||||
match && (webVersion = match[1]);
|
match && (webVersion = match[1]);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (!webVersion) {
|
||||||
// Get version from <meta>
|
// Get version from <meta>
|
||||||
// Sometimes this value is missing
|
// Sometimes this value is missing
|
||||||
webVersion = (document.querySelector<HTMLMetaElement>('meta[name=gamepass-app-version]'))?.content ?? '';
|
webVersion = (document.querySelector<HTMLMetaElement>('meta[name=gamepass-app-version]'))?.content ?? '';
|
||||||
|
@ -267,6 +267,10 @@ export class TouchController {
|
|||||||
return TouchController.#customList;
|
return TouchController.#customList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static hasCustomControl(productId: string): boolean {
|
||||||
|
return TouchController.#customList?.includes(productId);
|
||||||
|
}
|
||||||
|
|
||||||
static setup() {
|
static setup() {
|
||||||
// Function for testing touch control
|
// Function for testing touch control
|
||||||
window.testTouchLayout = (layout: any) => {
|
window.testTouchLayout = (layout: any) => {
|
||||||
|
@ -261,4 +261,9 @@ export const BxExposed = {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} : () => {},
|
} : () => {},
|
||||||
|
|
||||||
|
hasCustomTouchControl: TouchController.hasCustomControl,
|
||||||
|
hasCustomNativeMkb: (productId: string) => {
|
||||||
|
return BX_FLAGS.ForceNativeMkbTitles?.includes(productId);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user