Update better-xcloud.user.js

This commit is contained in:
redphx 2024-07-13 12:26:53 +07:00
parent 45bda4bb24
commit b6746598a3

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Better xCloud // @name Better xCloud
// @namespace https://github.com/redphx // @namespace https://github.com/redphx
// @version 5.1.1 // @version 5.1.2-beta
// @description Improve Xbox Cloud Gaming (xCloud) experience // @description Improve Xbox Cloud Gaming (xCloud) experience
// @author redphx // @author redphx
// @license MIT // @license MIT
@ -111,7 +111,7 @@ function deepClone(obj) {
return obj; return obj;
return JSON.parse(JSON.stringify(obj)); return JSON.parse(JSON.stringify(obj));
} }
var SCRIPT_VERSION = "5.1.1", AppInterface = window.AppInterface; var SCRIPT_VERSION = "5.1.2-beta", 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 = {
isPlaying: !1, isPlaying: !1,
@ -4897,7 +4897,7 @@ var clearApplicationInsightsBuffers = function() {
const port = options.consoleAddrs[ip]; const port = options.consoleAddrs[ip];
newCandidates.push(newCandidate(`a=candidate:${newCandidates.length + 1} 1 UDP 1 ${ip} ${port} typ host`)); newCandidates.push(newCandidate(`a=candidate:${newCandidates.length + 1} 1 UDP 1 ${ip} ${port} typ host`));
} }
return newCandidates.push(newCandidate("a=end-of-candidates")), console.log(newCandidates), newCandidates; return newCandidates.push(newCandidate("a=end-of-candidates")), BxLogger.info("ICE Candidates", newCandidates), newCandidates;
}; };
async function patchIceCandidates(request, consoleAddrs) { async function patchIceCandidates(request, consoleAddrs) {
const response = await NATIVE_FETCH(request), text = await response.clone().text(); const response = await NATIVE_FETCH(request), text = await response.clone().text();
@ -5025,6 +5025,8 @@ class XhomeInterceptor {
const response = await NATIVE_FETCH(request), obj = await response.clone().json(); const response = await NATIVE_FETCH(request), obj = await response.clone().json();
console.log(obj); console.log(obj);
const serverDetails = obj.serverDetails; const serverDetails = obj.serverDetails;
if (serverDetails.ipAddress)
XhomeInterceptor.#consoleAddrs[serverDetails.ipAddress] = serverDetails.port;
if (serverDetails.ipV4Address) if (serverDetails.ipV4Address)
XhomeInterceptor.#consoleAddrs[serverDetails.ipV4Address] = serverDetails.ipV4Port; XhomeInterceptor.#consoleAddrs[serverDetails.ipV4Address] = serverDetails.ipV4Port;
if (serverDetails.ipV6Address) if (serverDetails.ipV6Address)
@ -6693,6 +6695,10 @@ function patchMeControl() {
setDisplayMode: () => { setDisplayMode: () => {
}, },
setMobileState: () => { setMobileState: () => {
},
addEventListener: () => {
},
removeEventListener: () => {
} }
} }
} }
@ -7156,13 +7162,17 @@ var unload = function() {
if (getPref(PrefKey.MKB_ENABLED) && AppInterface) if (getPref(PrefKey.MKB_ENABLED) && AppInterface)
STATES.pointerServerPort = AppInterface.startPointerServer() || 9269, BxLogger.info("startPointerServer", "Port", STATES.pointerServerPort.toString()); STATES.pointerServerPort = AppInterface.startPointerServer() || 9269, BxLogger.info("startPointerServer", "Port", STATES.pointerServerPort.toString());
}; };
if (window.location.pathname.includes("/auth/msa")) if (window.location.pathname.includes("/auth/msa")) {
throw window.addEventListener("load", (e) => { const nativePushState = window.history.pushState;
window.location.search.includes("loggedIn") && window.setTimeout(() => { throw window.history.pushState = function(...args) {
const location2 = window.location; const url = args[2];
location2.pathname.includes("/play") && location2.reload(!0); if (url && (url.startsWith("/play") || url.substring(6).startsWith("/play"))) {
}, 2000); window.stop(), window.location.href = "https://www.xbox.com" + url;
}), new Error("[Better xCloud] Refreshing the page after logging in"); return;
}
return nativePushState.apply(this, arguments);
}, new Error("[Better xCloud] Refreshing the page after logging in");
}
BxLogger.info("readyState", document.readyState); BxLogger.info("readyState", document.readyState);
if (BX_FLAGS.SafariWorkaround && document.readyState !== "loading") { if (BX_FLAGS.SafariWorkaround && document.readyState !== "loading") {
window.stop(); window.stop();