mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-01 13:17:20 +02:00
Fix script running on non-xCloud pages (#698)
This commit is contained in:
parent
1fb1a64767
commit
f4f88f688b
2
dist/better-xcloud.pretty.user.js
vendored
2
dist/better-xcloud.pretty.user.js
vendored
@ -7,6 +7,7 @@
|
||||
// @license MIT
|
||||
// @match https://www.xbox.com/*/play*
|
||||
// @match https://www.xbox.com/*/auth/msa?*loggedIn*
|
||||
// @exclude https://www.xbox.com/*/xbox-game-pass/play-day-one
|
||||
// @run-at document-start
|
||||
// @grant none
|
||||
// @updateURL https://raw.githubusercontent.com/redphx/better-xcloud/typescript/dist/better-xcloud.meta.js
|
||||
@ -10242,6 +10243,7 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== "loading") {
|
||||
class: "bx-reload-overlay"
|
||||
}, CE("div", !1, CE("p", !1, t("load-failed-message")), $secondaryAction))), document.documentElement.appendChild($fragment), isSafari && window.location.reload(!0), new Error("[Better xCloud] Executing workaround for Safari");
|
||||
}
|
||||
if (!window.location.pathname.match(/^\/[a-zA-Z]{2}-[a-zA-Z]{2}\/play/)) throw new Error("[Better xCloud] Not xCloud page");
|
||||
window.addEventListener("load", (e) => {
|
||||
window.setTimeout(() => {
|
||||
if (document.body.classList.contains("legacyBackground")) window.stop(), window.location.reload(!0);
|
||||
|
2
dist/better-xcloud.user.js
vendored
2
dist/better-xcloud.user.js
vendored
@ -7,6 +7,7 @@
|
||||
// @license MIT
|
||||
// @match https://www.xbox.com/*/play*
|
||||
// @match https://www.xbox.com/*/auth/msa?*loggedIn*
|
||||
// @exclude https://www.xbox.com/*/xbox-game-pass/play-day-one
|
||||
// @run-at document-start
|
||||
// @grant none
|
||||
// @updateURL https://raw.githubusercontent.com/redphx/better-xcloud/typescript/dist/better-xcloud.meta.js
|
||||
@ -294,6 +295,7 @@ SettingsManager.getInstance();
|
||||
if (window.location.pathname.includes("/auth/msa")) {let nativePushState = window.history.pushState;throw window.history.pushState = function(...args) {let url = args[2];if (url && (url.startsWith("/play") || url.substring(6).startsWith("/play"))) {console.log("Redirecting to xbox.com/play"), window.stop(), window.location.href = "https://www.xbox.com" + url;return;}return nativePushState.apply(this, arguments);}, new Error("[Better xCloud] Refreshing the page after logging in");}
|
||||
BxLogger.info("readyState", document.readyState);
|
||||
if (BX_FLAGS.SafariWorkaround && document.readyState !== "loading") {window.stop();let css = "";css += '.bx-reload-overlay{position:fixed;top:0;bottom:0;left:0;right:0;display:flex;align-items:center;background:rgba(0,0,0,0.8);z-index:9999;color:#fff;text-align:center;font-weight:400;font-family:"Segoe UI",Arial,Helvetica,sans-serif;font-size:1.3rem}.bx-reload-overlay *:focus{outline:none !important}.bx-reload-overlay > div{margin:0 auto}.bx-reload-overlay a{text-decoration:none;display:inline-block;background:#107c10;color:#fff;border-radius:4px;padding:6px}';let isSafari = UserAgent.isSafari(), $secondaryAction;if (isSafari) $secondaryAction = CE("p", !1, t("settings-reloading"));else $secondaryAction = CE("a", {href: "https://better-xcloud.github.io/troubleshooting",target: "_blank"}, "🤓 " + t("how-to-fix"));let $fragment = document.createDocumentFragment();throw $fragment.appendChild(CE("style", !1, css)), $fragment.appendChild(CE("div", {class: "bx-reload-overlay"}, CE("div", !1, CE("p", !1, t("load-failed-message")), $secondaryAction))), document.documentElement.appendChild($fragment), isSafari && window.location.reload(!0), new Error("[Better xCloud] Executing workaround for Safari");}
|
||||
if (!window.location.pathname.match(/^\/[a-zA-Z]{2}-[a-zA-Z]{2}\/play/)) throw new Error("[Better xCloud] Not xCloud page");
|
||||
window.addEventListener("load", (e) => {window.setTimeout(() => {if (document.body.classList.contains("legacyBackground")) window.stop(), window.location.reload(!0);}, 3000);});
|
||||
document.addEventListener("readystatechange", (e) => {if (document.readyState !== "interactive") return;if (STATES.isSignedIn = !!window.xbcUser?.isSignedIn, STATES.isSignedIn) RemotePlayManager.getInstance()?.initialize();if (getGlobalPref("ui.hideSections").includes("friends") || getGlobalPref("block.features").includes("friends")) {let $parent = document.querySelector("div[class*=PlayWithFriendsSkeleton]")?.closest("div[class*=HomePage-module]");$parent && ($parent.style.display = "none");}preloadFonts();});
|
||||
window.BX_EXPOSED = BxExposed;
|
||||
|
@ -7,6 +7,7 @@
|
||||
// @license MIT
|
||||
// @match https://www.xbox.com/*/play*
|
||||
// @match https://www.xbox.com/*/auth/msa?*loggedIn*
|
||||
// @exclude https://www.xbox.com/*/xbox-game-pass/play-day-one
|
||||
// @run-at document-start
|
||||
// @grant none
|
||||
// @updateURL https://raw.githubusercontent.com/redphx/better-xcloud/typescript/dist/better-xcloud.meta.js
|
||||
|
@ -147,6 +147,12 @@ if (isFullVersion() && BX_FLAGS.SafariWorkaround && document.readyState !== 'loa
|
||||
throw new Error('[Better xCloud] Executing workaround for Safari');
|
||||
}
|
||||
|
||||
// Make sure it only run on /play
|
||||
if (!window.location.pathname.match(/^\/[a-zA-Z]{2}-[a-zA-Z]{2}\/play/)) {
|
||||
throw new Error('[Better xCloud] Not xCloud page');
|
||||
}
|
||||
|
||||
|
||||
window.addEventListener('load', e => {
|
||||
// Automatically reload the page when running into the "We are sorry..." error message
|
||||
window.setTimeout(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user