Fix script not being loaded after refreshing token

This commit is contained in:
redphx 2024-07-13 12:19:07 +07:00
parent c93db035f3
commit 45bda4bb24
2 changed files with 15 additions and 7 deletions

View File

@ -37,13 +37,19 @@ import { updateVideoPlayer } from "./modules/stream/stream-settings-utils";
// Handle login page // Handle login page
if (window.location.pathname.includes('/auth/msa')) { if (window.location.pathname.includes('/auth/msa')) {
window.addEventListener('load', e => { const nativePushState = window.history['pushState'];
window.location.search.includes('loggedIn') && window.setTimeout(() => { window.history['pushState'] = function(...args: any[]) {
const location = window.location; const url = args[2];
// @ts-ignore if (url && (url.startsWith('/play') || url.substring(6).startsWith('/play'))) {
location.pathname.includes('/play') && location.reload(true); console.log('Redirecting to xbox.com/play');
}, 2000); window.stop();
}); window.location.href = 'https://www.xbox.com' + url;
return;
}
// @ts-ignore
return nativePushState.apply(this, arguments);
}
// Stop processing the script // Stop processing the script
throw new Error('[Better xCloud] Refreshing the page after logging in'); throw new Error('[Better xCloud] Refreshing the page after logging in');
} }

View File

@ -161,6 +161,8 @@ export function patchMeControl() {
API: { API: {
setDisplayMode: () => {}, setDisplayMode: () => {},
setMobileState: () => {}, setMobileState: () => {},
addEventListener: () => {},
removeEventListener: () => {},
}, },
}, },
}; };