mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-07-06 22:31:44 +02:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
55d7796f96 | |||
0b02a758db | |||
3b2abbf6bb | |||
43a66db697 |
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.4
|
// @version 6.4.5
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
38
dist/better-xcloud.pretty.user.js
vendored
38
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.4
|
// @version 6.4.5
|
||||||
// @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.4", SCRIPT_VARIANT = "full", AppInterface = window.AppInterface;
|
var SCRIPT_VERSION = "6.4.5", 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,
|
||||||
@ -4981,7 +4981,7 @@ class TouchController {
|
|||||||
}
|
}
|
||||||
if (!layoutId) layoutId = TouchController.#customLayouts[xboxTitleId]?.default_layout || null;
|
if (!layoutId) layoutId = TouchController.#customLayouts[xboxTitleId]?.default_layout || null;
|
||||||
if (!layoutId) {
|
if (!layoutId) {
|
||||||
BxLogger.error(LOG_TAG, "Invalid layoutId, show default controller"), TouchController.#enabled && TouchController.#showDefault();
|
BxLogger.warning(LOG_TAG, "Invalid layoutId, show default controller"), TouchController.#enabled && TouchController.#showDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let layoutChanged = TouchController.#currentLayoutId !== layoutId;
|
let layoutChanged = TouchController.#currentLayoutId !== layoutId;
|
||||||
@ -5133,11 +5133,6 @@ var LOG_TAG2 = "Patcher", PATCHES = {
|
|||||||
if (index < 0 || PatcherUtils.indexOf(str, '"AppInsightsCore', index, 200) < 0) return !1;
|
if (index < 0 || PatcherUtils.indexOf(str, '"AppInsightsCore', index, 200) < 0) return !1;
|
||||||
return PatcherUtils.replaceWith(str, index, text, ".track=function(e){},!!function(");
|
return PatcherUtils.replaceWith(str, index, text, ".track=function(e){},!!function(");
|
||||||
},
|
},
|
||||||
disableTelemetry(str) {
|
|
||||||
let text = ".disableTelemetry=function(){return!1}";
|
|
||||||
if (!str.includes(text)) return !1;
|
|
||||||
return str.replace(text, ".disableTelemetry=function(){return!0}");
|
|
||||||
},
|
|
||||||
disableTelemetryProvider(str) {
|
disableTelemetryProvider(str) {
|
||||||
let text = "this.enableLightweightTelemetry=!";
|
let text = "this.enableLightweightTelemetry=!";
|
||||||
if (!str.includes(text)) return !1;
|
if (!str.includes(text)) return !1;
|
||||||
@ -5165,10 +5160,10 @@ var LOG_TAG2 = "Patcher", PATCHES = {
|
|||||||
let layout = getGlobalPref("ui.layout") === "tv" ? "tv" : "default";
|
let layout = getGlobalPref("ui.layout") === "tv" ? "tv" : "default";
|
||||||
return str.replace(text, `?"${layout}":"${layout}"`);
|
return str.replace(text, `?"${layout}":"${layout}"`);
|
||||||
},
|
},
|
||||||
remotePlayDirectConnectUrl(str) {
|
remotePlayPostStreamRedirectUrl(str) {
|
||||||
let index = str.indexOf("/direct-connect");
|
let text = ".RemotePlayRoot.getLink()):";
|
||||||
if (index < 0) return !1;
|
if (!str.includes(text)) return !1;
|
||||||
return str.replace(str.substring(index - 9, index + 15), "https://www.xbox.com/play");
|
return str = str.replace(text, ".Home.getLink()):"), str;
|
||||||
},
|
},
|
||||||
remotePlayKeepAlive(str) {
|
remotePlayKeepAlive(str) {
|
||||||
let text = "onServerDisconnectMessage(e){";
|
let text = "onServerDisconnectMessage(e){";
|
||||||
@ -5212,14 +5207,14 @@ remotePlayServerId: (window.BX_REMOTE_PLAY_CONFIG && window.BX_REMOTE_PLAY_CONFI
|
|||||||
return customizationCode += renderString(controller_customization_default, { xCloudGamepadVar }), codeBlock = PatcherUtils.insertAt(codeBlock, backetIndex, customizationCode), str = str.substring(0, index) + codeBlock + str.substring(setTimeoutIndex), str;
|
return customizationCode += renderString(controller_customization_default, { xCloudGamepadVar }), codeBlock = PatcherUtils.insertAt(codeBlock, backetIndex, customizationCode), str = str.substring(0, index) + codeBlock + str.substring(setTimeoutIndex), str;
|
||||||
},
|
},
|
||||||
enableXcloudLogger(str) {
|
enableXcloudLogger(str) {
|
||||||
let text = "this.telemetryProvider=e}log(e,t,r){";
|
let index = str.indexOf("this.telemetryProvider.trackErrorLike");
|
||||||
if (!str.includes(text)) return !1;
|
if (index > -1 && (index = PatcherUtils.lastIndexOf(str, "}log(", index, 1500)), index > -1 && (index = PatcherUtils.indexOf(str, "{", index, 30, !0)), index < 0) return !1;
|
||||||
let newCode = `
|
let newCode = `
|
||||||
const [logTag, logLevel, logMessage] = Array.from(arguments);
|
const [logTag, logLevel, logMessage] = Array.from(arguments);
|
||||||
const logFunc = [console.debug, console.log, console.warn, console.error][logLevel];
|
const logFunc = [console.debug, console.log, console.warn, console.error][logLevel];
|
||||||
logFunc(logTag, '//', logMessage);
|
logFunc(logTag, '//', logMessage);
|
||||||
`;
|
`;
|
||||||
return str = str.replaceAll(text, text + newCode), str;
|
return str = PatcherUtils.insertAt(str, index, newCode), str;
|
||||||
},
|
},
|
||||||
enableConsoleLogging(str) {
|
enableConsoleLogging(str) {
|
||||||
let text = "static isConsoleLoggingAllowed(){";
|
let text = "static isConsoleLoggingAllowed(){";
|
||||||
@ -5548,11 +5543,6 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
|||||||
if (index >= 0 && (index = str.indexOf('addEventListener("touchstart"', index)), index >= 0 && (index = PatcherUtils.lastIndexOf(str, "return ", index, 50)), index < 0) return !1;
|
if (index >= 0 && (index = str.indexOf('addEventListener("touchstart"', index)), index >= 0 && (index = PatcherUtils.lastIndexOf(str, "return ", index, 50)), index < 0) return !1;
|
||||||
return str = PatcherUtils.replaceWith(str, index, "return", "return () => {};"), str;
|
return str = PatcherUtils.replaceWith(str, index, "return", "return () => {};"), str;
|
||||||
},
|
},
|
||||||
optimizeGameSlugGenerator(str) {
|
|
||||||
let text = "/[;,/?:@&=+_`~$%#^*()!^\\u2122\\xae\\xa9]/g";
|
|
||||||
if (!str.includes(text)) return !1;
|
|
||||||
return str = str.replace(text, "window.BX_EXPOSED.GameSlugRegexes[0]"), str = str.replace("/ {2,}/g", "window.BX_EXPOSED.GameSlugRegexes[1]"), str = str.replace("/ /g", "window.BX_EXPOSED.GameSlugRegexes[2]"), str;
|
|
||||||
},
|
|
||||||
modifyPreloadedState(str) {
|
modifyPreloadedState(str) {
|
||||||
let text = "=window.__PRELOADED_STATE__;";
|
let text = "=window.__PRELOADED_STATE__;";
|
||||||
if (!str.includes(text)) return !1;
|
if (!str.includes(text)) return !1;
|
||||||
@ -5669,7 +5659,6 @@ ${subsVar} = subs;
|
|||||||
"broadcastPollingMode",
|
"broadcastPollingMode",
|
||||||
getGlobalPref("ui.gameCard.waitTime.show") && "patchSetCurrentFocus",
|
getGlobalPref("ui.gameCard.waitTime.show") && "patchSetCurrentFocus",
|
||||||
"patchGamepadPolling",
|
"patchGamepadPolling",
|
||||||
"optimizeGameSlugGenerator",
|
|
||||||
"modifyPreloadedState",
|
"modifyPreloadedState",
|
||||||
"detectBrowserRouterReady",
|
"detectBrowserRouterReady",
|
||||||
"exposeStreamSession",
|
"exposeStreamSession",
|
||||||
@ -5699,13 +5688,11 @@ ${subsVar} = subs;
|
|||||||
] : [],
|
] : [],
|
||||||
...getGlobalPref("block.tracking") ? [
|
...getGlobalPref("block.tracking") ? [
|
||||||
"disableAiTrack",
|
"disableAiTrack",
|
||||||
"disableTelemetry",
|
|
||||||
"blockWebRtcStatsCollector",
|
"blockWebRtcStatsCollector",
|
||||||
"disableIndexDbLogging",
|
"disableIndexDbLogging",
|
||||||
"disableTelemetryProvider"
|
"disableTelemetryProvider"
|
||||||
] : [],
|
] : [],
|
||||||
...getGlobalPref("xhome.enabled") ? [
|
...getGlobalPref("xhome.enabled") ? [
|
||||||
"remotePlayDirectConnectUrl",
|
|
||||||
"remotePlayKeepAlive",
|
"remotePlayKeepAlive",
|
||||||
"remotePlayDisableAchievementToast",
|
"remotePlayDisableAchievementToast",
|
||||||
STATES.userAgent.capabilities.touch && "patchUpdateInputConfigurationAsync"
|
STATES.userAgent.capabilities.touch && "patchUpdateInputConfigurationAsync"
|
||||||
@ -5748,6 +5735,7 @@ ${subsVar} = subs;
|
|||||||
"patchPollGamepads",
|
"patchPollGamepads",
|
||||||
getGlobalPref("stream.video.combineAudio") && "streamCombineSources",
|
getGlobalPref("stream.video.combineAudio") && "streamCombineSources",
|
||||||
...getGlobalPref("xhome.enabled") ? [
|
...getGlobalPref("xhome.enabled") ? [
|
||||||
|
"remotePlayPostStreamRedirectUrl",
|
||||||
"patchRemotePlayMkb",
|
"patchRemotePlayMkb",
|
||||||
"remotePlayConnectMode"
|
"remotePlayConnectMode"
|
||||||
] : [],
|
] : [],
|
||||||
@ -8585,7 +8573,7 @@ class XhomeInterceptor {
|
|||||||
if (hasTouchSupport) TouchController.disable(), BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
if (hasTouchSupport) TouchController.disable(), BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
||||||
data: null
|
data: null
|
||||||
});
|
});
|
||||||
else TouchController.enable(), TouchController.requestCustomLayouts(xboxTitleId);
|
else TouchController.enable(), TouchController.requestCustomLayouts();
|
||||||
return response.json = () => Promise.resolve(obj), response.text = () => Promise.resolve(JSON.stringify(obj)), response;
|
return response.json = () => Promise.resolve(obj), response.text = () => Promise.resolve(JSON.stringify(obj)), response;
|
||||||
}
|
}
|
||||||
static async handleTitles(request) {
|
static async handleTitles(request) {
|
||||||
@ -9568,7 +9556,7 @@ function patchVideoApi() {
|
|||||||
return nativePlay.apply(this);
|
return nativePlay.apply(this);
|
||||||
}
|
}
|
||||||
let $parent = this.parentElement;
|
let $parent = this.parentElement;
|
||||||
if (!this.src && $parent.dataset.testid === "media-container") this.addEventListener("loadedmetadata", showFunc, { once: !0 });
|
if (!this.src && $parent?.dataset.testid === "media-container") this.addEventListener("loadedmetadata", showFunc, { once: !0 });
|
||||||
return nativePlay.apply(this);
|
return nativePlay.apply(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
22
dist/better-xcloud.user.js
vendored
22
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -39,6 +39,7 @@ const PATCHES = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Set disableTelemetry() to true
|
// Set disableTelemetry() to true
|
||||||
|
/*
|
||||||
disableTelemetry(str: string) {
|
disableTelemetry(str: string) {
|
||||||
let text = '.disableTelemetry=function(){return!1}';
|
let text = '.disableTelemetry=function(){return!1}';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
@ -47,6 +48,7 @@ const PATCHES = {
|
|||||||
|
|
||||||
return str.replace(text, '.disableTelemetry=function(){return!0}');
|
return str.replace(text, '.disableTelemetry=function(){return!0}');
|
||||||
},
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
disableTelemetryProvider(str: string) {
|
disableTelemetryProvider(str: string) {
|
||||||
let text = 'this.enableLightweightTelemetry=!';
|
let text = 'this.enableLightweightTelemetry=!';
|
||||||
@ -91,14 +93,14 @@ const PATCHES = {
|
|||||||
return str.replace(text, `?"${layout}":"${layout}"`);
|
return str.replace(text, `?"${layout}":"${layout}"`);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Replace "/direct-connect" with "/play"
|
remotePlayPostStreamRedirectUrl(str: string) {
|
||||||
remotePlayDirectConnectUrl(str: string) {
|
let text = '.RemotePlayRoot.getLink()):';
|
||||||
const index = str.indexOf('/direct-connect');
|
if (!str.includes(text)) {
|
||||||
if (index < 0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str.replace(str.substring(index - 9, index + 15), 'https://www.xbox.com/play');
|
str = str.replace(text, '.Home.getLink()):');
|
||||||
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
remotePlayKeepAlive(str: string) {
|
remotePlayKeepAlive(str: string) {
|
||||||
@ -202,8 +204,11 @@ remotePlayServerId: (window.BX_REMOTE_PLAY_CONFIG && window.BX_REMOTE_PLAY_CONFI
|
|||||||
},
|
},
|
||||||
|
|
||||||
enableXcloudLogger(str: string) {
|
enableXcloudLogger(str: string) {
|
||||||
let text = 'this.telemetryProvider=e}log(e,t,r){';
|
let index = str.indexOf('this.telemetryProvider.trackErrorLike');
|
||||||
if (!str.includes(text)) {
|
index > -1 && (index = PatcherUtils.lastIndexOf(str, '}log(', index, 1500));
|
||||||
|
index > -1 && (index = PatcherUtils.indexOf(str, '{', index, 30, true));
|
||||||
|
|
||||||
|
if (index < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +218,7 @@ const logFunc = [console.debug, console.log, console.warn, console.error][logLev
|
|||||||
logFunc(logTag, '//', logMessage);
|
logFunc(logTag, '//', logMessage);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
str = str.replaceAll(text, text + newCode);
|
str = PatcherUtils.insertAt(str, index, newCode);
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -909,20 +914,6 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
|||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Optimize Game slug generator by using cached RegEx
|
|
||||||
optimizeGameSlugGenerator(str: string) {
|
|
||||||
let text = '/[;,/?:@&=+_`~$%#^*()!^\\u2122\\xae\\xa9]/g';
|
|
||||||
if (!str.includes(text)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
str = str.replace(text, 'window.BX_EXPOSED.GameSlugRegexes[0]');
|
|
||||||
str = str.replace('/ {2,}/g', 'window.BX_EXPOSED.GameSlugRegexes[1]');
|
|
||||||
str = str.replace('/ /g', 'window.BX_EXPOSED.GameSlugRegexes[2]');
|
|
||||||
|
|
||||||
return str;
|
|
||||||
},
|
|
||||||
|
|
||||||
modifyPreloadedState(str: string) {
|
modifyPreloadedState(str: string) {
|
||||||
let text = '=window.__PRELOADED_STATE__;';
|
let text = '=window.__PRELOADED_STATE__;';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
@ -1219,8 +1210,6 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
|
|||||||
|
|
||||||
'patchGamepadPolling',
|
'patchGamepadPolling',
|
||||||
|
|
||||||
'optimizeGameSlugGenerator',
|
|
||||||
|
|
||||||
'modifyPreloadedState',
|
'modifyPreloadedState',
|
||||||
|
|
||||||
'detectBrowserRouterReady',
|
'detectBrowserRouterReady',
|
||||||
@ -1269,7 +1258,7 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
|
|||||||
|
|
||||||
...(getGlobalPref(GlobalPref.BLOCK_TRACKING) ? [
|
...(getGlobalPref(GlobalPref.BLOCK_TRACKING) ? [
|
||||||
'disableAiTrack',
|
'disableAiTrack',
|
||||||
'disableTelemetry',
|
// 'disableTelemetry',
|
||||||
|
|
||||||
'blockWebRtcStatsCollector',
|
'blockWebRtcStatsCollector',
|
||||||
'disableIndexDbLogging',
|
'disableIndexDbLogging',
|
||||||
@ -1278,7 +1267,6 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
|
|||||||
] : []) as PatchArray,
|
] : []) as PatchArray,
|
||||||
|
|
||||||
...(getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED) ? [
|
...(getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED) ? [
|
||||||
'remotePlayDirectConnectUrl',
|
|
||||||
'remotePlayKeepAlive',
|
'remotePlayKeepAlive',
|
||||||
'remotePlayDisableAchievementToast',
|
'remotePlayDisableAchievementToast',
|
||||||
STATES.userAgent.capabilities.touch && 'patchUpdateInputConfigurationAsync',
|
STATES.userAgent.capabilities.touch && 'patchUpdateInputConfigurationAsync',
|
||||||
@ -1348,6 +1336,7 @@ let STREAM_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
|||||||
getGlobalPref(GlobalPref.STREAM_COMBINE_SOURCES) && 'streamCombineSources',
|
getGlobalPref(GlobalPref.STREAM_COMBINE_SOURCES) && 'streamCombineSources',
|
||||||
|
|
||||||
...(getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED) ? [
|
...(getGlobalPref(GlobalPref.REMOTE_PLAY_ENABLED) ? [
|
||||||
|
'remotePlayPostStreamRedirectUrl',
|
||||||
'patchRemotePlayMkb',
|
'patchRemotePlayMkb',
|
||||||
'remotePlayConnectMode',
|
'remotePlayConnectMode',
|
||||||
] : []) as PatchArray,
|
] : []) as PatchArray,
|
||||||
|
@ -209,7 +209,7 @@ export class TouchController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!layoutId) {
|
if (!layoutId) {
|
||||||
BxLogger.error(LOG_TAG, 'Invalid layoutId, show default controller');
|
BxLogger.warning(LOG_TAG, 'Invalid layoutId, show default controller');
|
||||||
TouchController.#enabled && TouchController.#showDefault();
|
TouchController.#enabled && TouchController.#showDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,9 @@ export function patchVideoApi() {
|
|||||||
return nativePlay.apply(this);
|
return nativePlay.apply(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const $parent = this.parentElement!!;
|
const $parent = this.parentElement;
|
||||||
// Video tag is stream player
|
// Video tag is stream player
|
||||||
if (!this.src && $parent.dataset.testid === 'media-container') {
|
if (!this.src && $parent?.dataset.testid === 'media-container') {
|
||||||
this.addEventListener('loadedmetadata', showFunc, { once: true });
|
this.addEventListener('loadedmetadata', showFunc, { once: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ export class XhomeInterceptor {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
TouchController.enable();
|
TouchController.enable();
|
||||||
TouchController.requestCustomLayouts(xboxTitleId);
|
TouchController.requestCustomLayouts();
|
||||||
}
|
}
|
||||||
|
|
||||||
response.json = () => Promise.resolve(obj);
|
response.json = () => Promise.resolve(obj);
|
||||||
|
Reference in New Issue
Block a user