mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-30 03:11:43 +02:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
69d7cbfffb | |||
92e6828cb2 | |||
12ad81e9c7 | |||
102e0bd318 | |||
9308963bc2 | |||
c90e013dc1 | |||
037927b9be | |||
dabab9acb1 | |||
a4a52c6bc3 | |||
eebd7434ea | |||
ec1805f832 | |||
34f959d5ae | |||
784a31ce43 | |||
df266d32fc | |||
a6ccd6666e | |||
fe609034d6 | |||
97ec29faa0 | |||
a34ae75131 | |||
139543aaa5 | |||
8099115959 | |||
21efa5ffdc | |||
07ebf3926b |
1
build.ts
1
build.ts
@ -41,6 +41,7 @@ const postProcess = (str: string): string => {
|
|||||||
return match;
|
return match;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
str = str.replaceAll('(e) => `', 'e => `');
|
||||||
|
|
||||||
assert(str.includes('/* ADDITIONAL CODE */'));
|
assert(str.includes('/* ADDITIONAL CODE */'));
|
||||||
assert(str.includes('window.BX_EXPOSED = BxExposed'));
|
assert(str.includes('window.BX_EXPOSED = BxExposed'));
|
||||||
|
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 5.7.2
|
// @version 5.7.5
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
803
dist/better-xcloud.user.js
vendored
803
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
12
package.json
12
package.json
@ -9,14 +9,14 @@
|
|||||||
"build": "build.ts"
|
"build": "build.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "^1.1.8",
|
"@types/bun": "^1.1.9",
|
||||||
"@types/node": "^22.5.2",
|
"@types/node": "^22.5.5",
|
||||||
"@types/stylus": "^0.48.42",
|
"@types/stylus": "^0.48.43",
|
||||||
"eslint": "^9.9.1",
|
"eslint": "^9.10.0",
|
||||||
"eslint-plugin-compat": "^6.0.0",
|
"eslint-plugin-compat": "^6.0.1",
|
||||||
"stylus": "^0.63.0"
|
"stylus": "^0.63.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.5.4"
|
"typescript": "^5.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
.bx-navigation-dialog {
|
.bx-navigation-dialog {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: var(--bx-navigation-dialog-z-index);
|
z-index: var(--bx-navigation-dialog-z-index);
|
||||||
|
font-family: var(--bx-title-font);
|
||||||
|
|
||||||
|
*:focus {
|
||||||
|
outline: none !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-navigation-dialog-overlay {
|
.bx-navigation-dialog-overlay {
|
||||||
|
@ -1,36 +1,16 @@
|
|||||||
.bx-remote-play-popup {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 1920px;
|
|
||||||
margin: auto;
|
|
||||||
position: relative;
|
|
||||||
height: 0.1px;
|
|
||||||
overflow: visible;
|
|
||||||
z-index: var(--bx-remote-play-popup-z-index);
|
|
||||||
}
|
|
||||||
|
|
||||||
.bx-remote-play-container {
|
.bx-remote-play-container {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
right: 10px;
|
top: 50%;
|
||||||
top: 0;
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
|
||||||
|
color: white;
|
||||||
background: #1a1b1e;
|
background: #1a1b1e;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
width: 420px;
|
width: 420px;
|
||||||
max-width: calc(100vw - 20px);
|
max-width: calc(100vw - 20px);
|
||||||
margin: 0 0 0 auto;
|
margin: 0 0 0 auto;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
box-shadow: #00000080 0px 0px 12px 0px;
|
|
||||||
|
|
||||||
@media (min-width:480px) and (min-height:calc(480px + 1px)) {
|
|
||||||
right: calc(env(safe-area-inset-right, 0px) + 32px);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width:768px) and (min-height:calc(480px + 1px)) {
|
|
||||||
right: calc(env(safe-area-inset-right, 0px) + 48px);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width:1920px) and (min-height:calc(480px + 1px)) {
|
|
||||||
right: calc(env(safe-area-inset-right, 0px) + 80px);
|
|
||||||
}
|
|
||||||
|
|
||||||
> .bx-button {
|
> .bx-button {
|
||||||
display: table;
|
display: table;
|
||||||
@ -121,3 +101,8 @@
|
|||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
margin: 4px 0;
|
margin: 4px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bx-remote-play-buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
@ -37,8 +37,6 @@ button_color(name, normal, hover, active, disabled)
|
|||||||
--bx-navigation-dialog-z-index: 30100;
|
--bx-navigation-dialog-z-index: 30100;
|
||||||
--bx-navigation-dialog-overlay-z-index: 30000;
|
--bx-navigation-dialog-overlay-z-index: 30000;
|
||||||
|
|
||||||
--bx-remote-play-popup-z-index: 20000;
|
|
||||||
|
|
||||||
--bx-game-bar-z-index: 10000;
|
--bx-game-bar-z-index: 10000;
|
||||||
--bx-screenshot-animation-z-index: 9000;
|
--bx-screenshot-animation-z-index: 9000;
|
||||||
--bx-wait-time-box-z-index: 1000;
|
--bx-wait-time-box-z-index: 1000;
|
||||||
|
@ -130,7 +130,6 @@
|
|||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
border-color: #fff;
|
border-color: #fff;
|
||||||
outline: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&[data-group=global] {
|
&[data-group=global] {
|
||||||
@ -234,11 +233,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus,
|
|
||||||
*:focus {
|
|
||||||
outline: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bx-top-buttons {
|
.bx-top-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -16,7 +16,7 @@ import { MouseCursorHider } from "@modules/mkb/mouse-cursor-hider";
|
|||||||
import { TouchController } from "@modules/touch-controller";
|
import { TouchController } from "@modules/touch-controller";
|
||||||
import { checkForUpdate, disablePwa, productTitleToSlug } from "@utils/utils";
|
import { checkForUpdate, disablePwa, productTitleToSlug } from "@utils/utils";
|
||||||
import { Patcher } from "@modules/patcher";
|
import { Patcher } from "@modules/patcher";
|
||||||
import { RemotePlay } from "@modules/remote-play";
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
import { onHistoryChanged, patchHistoryMethod } from "@utils/history";
|
import { onHistoryChanged, patchHistoryMethod } from "@utils/history";
|
||||||
import { VibrationManager } from "@modules/vibration-manager";
|
import { VibrationManager } from "@modules/vibration-manager";
|
||||||
import { overridePreloadState } from "@utils/preload-state";
|
import { overridePreloadState } from "@utils/preload-state";
|
||||||
@ -157,7 +157,7 @@ document.addEventListener('readystatechange', e => {
|
|||||||
|
|
||||||
if (STATES.isSignedIn) {
|
if (STATES.isSignedIn) {
|
||||||
// Preload Remote Play
|
// Preload Remote Play
|
||||||
getPref(PrefKey.REMOTE_PLAY_ENABLED) && RemotePlay.preload();
|
getPref(PrefKey.REMOTE_PLAY_ENABLED) && RemotePlayManager.getInstance().initialize();
|
||||||
} else {
|
} else {
|
||||||
// Show Settings button in the header when not signed in
|
// Show Settings button in the header when not signed in
|
||||||
window.setTimeout(HeaderSection.watchHeader, 2000);
|
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||||
@ -413,7 +413,7 @@ function main() {
|
|||||||
|
|
||||||
// Preload Remote Play
|
// Preload Remote Play
|
||||||
if (getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
if (getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
||||||
RemotePlay.detect();
|
RemotePlayManager.detect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.ALL) {
|
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === StreamTouchController.ALL) {
|
||||||
|
@ -78,7 +78,7 @@ export class GameBar {
|
|||||||
$container.addEventListener('transitionend', e => {
|
$container.addEventListener('transitionend', e => {
|
||||||
const classList = $container.classList;
|
const classList = $container.classList;
|
||||||
if (classList.contains('bx-hide')) {
|
if (classList.contains('bx-hide')) {
|
||||||
classList.remove('bx-offscreen', 'bx-hide');
|
classList.remove('bx-hide');
|
||||||
classList.add('bx-offscreen');
|
classList.add('bx-offscreen');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -135,6 +135,8 @@ export class GameBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hideBar() {
|
hideBar() {
|
||||||
|
this.clearHideTimeout();
|
||||||
|
|
||||||
// Stop focusing Game Bar
|
// Stop focusing Game Bar
|
||||||
clearFocus();
|
clearFocus();
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ const LOG_TAG = 'Patcher';
|
|||||||
const PATCHES = {
|
const PATCHES = {
|
||||||
// Disable ApplicationInsights.track() function
|
// Disable ApplicationInsights.track() function
|
||||||
disableAiTrack(str: string) {
|
disableAiTrack(str: string) {
|
||||||
const text = '.track=function(';
|
let text = '.track=function(';
|
||||||
const index = str.indexOf(text);
|
const index = str.indexOf(text);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -69,7 +69,7 @@ const PATCHES = {
|
|||||||
|
|
||||||
// Set disableTelemetry() to true
|
// Set disableTelemetry() to true
|
||||||
disableTelemetry(str: string) {
|
disableTelemetry(str: string) {
|
||||||
const text = '.disableTelemetry=function(){return!1}';
|
let text = '.disableTelemetry=function(){return!1}';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ const PATCHES = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
disableTelemetryProvider(str: string) {
|
disableTelemetryProvider(str: string) {
|
||||||
const text = 'this.enableLightweightTelemetry=!';
|
let text = 'this.enableLightweightTelemetry=!';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ const PATCHES = {
|
|||||||
|
|
||||||
// Disable IndexDB logging
|
// Disable IndexDB logging
|
||||||
disableIndexDbLogging(str: string) {
|
disableIndexDbLogging(str: string) {
|
||||||
const text = ',this.logsDb=new';
|
let text = ',this.logsDb=new';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ const PATCHES = {
|
|||||||
|
|
||||||
// Set custom website layout
|
// Set custom website layout
|
||||||
websiteLayout(str: string) {
|
websiteLayout(str: string) {
|
||||||
const text = '?"tv":"default"';
|
let text = '?"tv":"default"';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ const PATCHES = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
remotePlayKeepAlive(str: string) {
|
remotePlayKeepAlive(str: string) {
|
||||||
const text = 'onServerDisconnectMessage(e){';
|
let text = 'onServerDisconnectMessage(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ const PATCHES = {
|
|||||||
|
|
||||||
// Enable Remote Play feature
|
// Enable Remote Play feature
|
||||||
remotePlayConnectMode(str: string) {
|
remotePlayConnectMode(str: string) {
|
||||||
const text = 'connectMode:"cloud-connect",';
|
let text = 'connectMode:"cloud-connect",';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -151,25 +151,44 @@ const PATCHES = {
|
|||||||
return str.replace(text, codeRemotePlayEnable);
|
return str.replace(text, codeRemotePlayEnable);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Disable achievement toast in Remote Play
|
// Remote Play: Disable achievement toast
|
||||||
remotePlayDisableAchievementToast(str: string) {
|
remotePlayDisableAchievementToast(str: string) {
|
||||||
const text = '.AchievementUnlock:{';
|
let text = '.AchievementUnlock:{';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newCode = `
|
const newCode = `if (!!window.BX_REMOTE_PLAY_CONFIG) return;`;
|
||||||
if (!!window.BX_REMOTE_PLAY_CONFIG) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
return str.replace(text, text + newCode);
|
return str.replace(text, text + newCode);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Remote Play: Prevent adding "Fortnite" to the "Jump back in" list
|
||||||
|
remotePlayRecentlyUsedTitleIds(str: string) {
|
||||||
|
let text = '(e.data.recentlyUsedTitleIds)){';
|
||||||
|
if (!str.includes(text)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newCode = `if (window.BX_REMOTE_PLAY_CONFIG) return;`;
|
||||||
|
return str.replace(text, text + newCode);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Remote Play: change web page's title
|
||||||
|
/*
|
||||||
|
remotePlayWebTitle(str: string) {
|
||||||
|
let text = '"undefined"!==typeof e&&document.title!==e';
|
||||||
|
if (!str.includes(text)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newCode = `if (window.BX_REMOTE_PLAY_CONFIG) { e = "${t('remote-play')} - ${t('better-xcloud')}"; }`;
|
||||||
|
return str.replace(text, newCode + text);
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
// Block WebRTC stats collector
|
// Block WebRTC stats collector
|
||||||
blockWebRtcStatsCollector(str: string) {
|
blockWebRtcStatsCollector(str: string) {
|
||||||
const text = 'this.shouldCollectStats=!0';
|
let text = 'this.shouldCollectStats=!0';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -210,7 +229,7 @@ if (!!window.BX_REMOTE_PLAY_CONFIG) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
enableXcloudLogger(str: string) {
|
enableXcloudLogger(str: string) {
|
||||||
const text = 'this.telemetryProvider=e}log(e,t,r){';
|
let text = 'this.telemetryProvider=e}log(e,t,r){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -226,7 +245,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
},
|
},
|
||||||
|
|
||||||
enableConsoleLogging(str: string) {
|
enableConsoleLogging(str: string) {
|
||||||
const text = 'static isConsoleLoggingAllowed(){';
|
let text = 'static isConsoleLoggingAllowed(){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -237,7 +256,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
|
|
||||||
// Control controller vibration
|
// Control controller vibration
|
||||||
playVibration(str: string) {
|
playVibration(str: string) {
|
||||||
const text = '}playVibration(e){';
|
let text = '}playVibration(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -278,7 +297,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchUpdateInputConfigurationAsync(str: string) {
|
patchUpdateInputConfigurationAsync(str: string) {
|
||||||
const text = 'async updateInputConfigurationAsync(e){';
|
let text = 'async updateInputConfigurationAsync(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -291,7 +310,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
|
|
||||||
// Add patches that are only needed when start playing
|
// Add patches that are only needed when start playing
|
||||||
loadingEndingChunks(str: string) {
|
loadingEndingChunks(str: string) {
|
||||||
const text = '"FamilySagaManager"';
|
let text = '"FamilySagaManager"';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -316,7 +335,7 @@ logFunc(logTag, '//', logMessage);
|
|||||||
},
|
},
|
||||||
|
|
||||||
exposeTouchLayoutManager(str: string) {
|
exposeTouchLayoutManager(str: string) {
|
||||||
const text = 'this._perScopeLayoutsStream=new';
|
let text = 'this._perScopeLayoutsStream=new';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -363,7 +382,7 @@ if (window.BX_EXPOSED.stopTakRendering) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
supportLocalCoOp(str: string) {
|
supportLocalCoOp(str: string) {
|
||||||
const text = 'this.gamepadMappingsToSend=[],';
|
let text = 'this.gamepadMappingsToSend=[],';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -375,7 +394,7 @@ if (window.BX_EXPOSED.stopTakRendering) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
forceFortniteConsole(str: string) {
|
forceFortniteConsole(str: string) {
|
||||||
const text = 'sendTouchInputEnabledMessage(e){';
|
let text = 'sendTouchInputEnabledMessage(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -387,7 +406,7 @@ if (window.BX_EXPOSED.stopTakRendering) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
disableTakRenderer(str: string) {
|
disableTakRenderer(str: string) {
|
||||||
const text = 'const{TakRenderer:';
|
let text = 'const{TakRenderer:';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -427,7 +446,7 @@ if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFak
|
|||||||
},
|
},
|
||||||
|
|
||||||
streamCombineSources(str: string) {
|
streamCombineSources(str: string) {
|
||||||
const text = 'this.useCombinedAudioVideoStream=!!this.deviceInformation.isTizen';
|
let text = 'this.useCombinedAudioVideoStream=!!this.deviceInformation.isTizen';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -437,7 +456,7 @@ if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFak
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchStreamHud(str: string) {
|
patchStreamHud(str: string) {
|
||||||
const text = 'let{onCollapse';
|
let text = 'let{onCollapse';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -459,7 +478,7 @@ e.guideUI = null;
|
|||||||
},
|
},
|
||||||
|
|
||||||
broadcastPollingMode(str: string) {
|
broadcastPollingMode(str: string) {
|
||||||
const text = '.setPollingMode=e=>{';
|
let text = '.setPollingMode=e=>{';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -483,7 +502,7 @@ BxEvent.dispatch(window, BxEvent.XCLOUD_POLLING_MODE_CHANGED, {mode: e.toLowerCa
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchXcloudTitleInfo(str: string) {
|
patchXcloudTitleInfo(str: string) {
|
||||||
const text = 'async cloudConnect';
|
let text = 'async cloudConnect';
|
||||||
let index = str.indexOf(text);
|
let index = str.indexOf(text);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -505,7 +524,7 @@ BxLogger.info('patchXcloudTitleInfo', ${titleInfoVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchRemotePlayMkb(str: string) {
|
patchRemotePlayMkb(str: string) {
|
||||||
const text = 'async homeConsoleConnect';
|
let text = 'async homeConsoleConnect';
|
||||||
let index = str.indexOf(text);
|
let index = str.indexOf(text);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -533,7 +552,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchAudioMediaStream(str: string) {
|
patchAudioMediaStream(str: string) {
|
||||||
const text = '.srcObject=this.audioMediaStream,';
|
let text = '.srcObject=this.audioMediaStream,';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -545,7 +564,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchCombinedAudioVideoMediaStream(str: string) {
|
patchCombinedAudioVideoMediaStream(str: string) {
|
||||||
const text = '.srcObject=this.combinedAudioVideoStream';
|
let text = '.srcObject=this.combinedAudioVideoStream';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -556,7 +575,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchTouchControlDefaultOpacity(str: string) {
|
patchTouchControlDefaultOpacity(str: string) {
|
||||||
const text = 'opacityMultiplier:1';
|
let text = 'opacityMultiplier:1';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -568,7 +587,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchShowSensorControls(str: string) {
|
patchShowSensorControls(str: string) {
|
||||||
const text = '{shouldShowSensorControls:';
|
let text = '{shouldShowSensorControls:';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -581,7 +600,7 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar});
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
exposeEventTarget(str: string) {
|
exposeEventTarget(str: string) {
|
||||||
const text ='this._eventTarget=new EventTarget';
|
let text ='this._eventTarget=new EventTarget';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -598,7 +617,7 @@ window.dispatchEvent(new Event('${BxEvent.STREAM_EVENT_TARGET_READY}'))
|
|||||||
|
|
||||||
// Class with: connectAsync(), doConnectAsync(), setPlayClient()
|
// Class with: connectAsync(), doConnectAsync(), setPlayClient()
|
||||||
exposeStreamSession(str: string) {
|
exposeStreamSession(str: string) {
|
||||||
const text =',this._connectionType=';
|
let text =',this._connectionType=';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -612,7 +631,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
skipFeedbackDialog(str: string) {
|
skipFeedbackDialog(str: string) {
|
||||||
const text = '&&this.shouldTransitionToFeedback(';
|
let text = '&&this.shouldTransitionToFeedback(';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -622,7 +641,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
enableNativeMkb(str: string) {
|
enableNativeMkb(str: string) {
|
||||||
const text = 'e.mouseSupported&&e.keyboardSupported&&e.fullscreenSupported;';
|
let text = 'e.mouseSupported&&e.keyboardSupported&&e.fullscreenSupported;';
|
||||||
if ((!str.includes(text))) {
|
if ((!str.includes(text))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -632,7 +651,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
patchMouseAndKeyboardEnabled(str: string) {
|
patchMouseAndKeyboardEnabled(str: string) {
|
||||||
const text = 'get mouseAndKeyboardEnabled(){';
|
let text = 'get mouseAndKeyboardEnabled(){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -642,7 +661,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
exposeInputSink(str: string) {
|
exposeInputSink(str: string) {
|
||||||
const text = 'this.controlChannel=null,this.inputChannel=null';
|
let text = 'this.controlChannel=null,this.inputChannel=null';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -654,7 +673,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
disableNativeRequestPointerLock(str: string) {
|
disableNativeRequestPointerLock(str: string) {
|
||||||
const text = 'async requestPointerLock(){';
|
let text = 'async requestPointerLock(){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -665,7 +684,7 @@ true` + text;
|
|||||||
|
|
||||||
// Fix crashing when RequestInfo.origin is empty
|
// Fix crashing when RequestInfo.origin is empty
|
||||||
patchRequestInfoCrash(str: string) {
|
patchRequestInfoCrash(str: string) {
|
||||||
const text = 'if(!e)throw new Error("RequestInfo.origin is falsy");';
|
let text = 'if(!e)throw new Error("RequestInfo.origin is falsy");';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -675,7 +694,7 @@ true` + text;
|
|||||||
},
|
},
|
||||||
|
|
||||||
exposeDialogRoutes(str: string) {
|
exposeDialogRoutes(str: string) {
|
||||||
const text = 'return{goBack:function(){';
|
let text = 'return{goBack:function(){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -830,7 +849,7 @@ if (e && e.id) {
|
|||||||
|
|
||||||
// Override Storage.getSettings()
|
// Override Storage.getSettings()
|
||||||
overrideStorageGetSettings(str: string) {
|
overrideStorageGetSettings(str: string) {
|
||||||
const text = '}getSetting(e){';
|
let text = '}getSetting(e){';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -894,7 +913,7 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
detectBrowserRouterReady(str: string) {
|
detectBrowserRouterReady(str: string) {
|
||||||
const text = 'BrowserRouter:()=>';
|
let text = 'BrowserRouter:()=>';
|
||||||
if (!str.includes(text)) {
|
if (!str.includes(text)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -912,6 +931,26 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
|||||||
str = PatcherUtils.insertAt(str, index, 'window.BxEvent.dispatch(window, window.BxEvent.XCLOUD_ROUTER_HISTORY_READY, {history: this.history});');
|
str = PatcherUtils.insertAt(str, index, 'window.BxEvent.dispatch(window, window.BxEvent.XCLOUD_ROUTER_HISTORY_READY, {history: this.history});');
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Set Achievements list's filter default to "Locked"
|
||||||
|
guideAchievementsDefaultLocked(str: string) {
|
||||||
|
let index = str.indexOf('FilterButton-module__container');
|
||||||
|
index >= 0 && (index = PatcherUtils.lastIndexOf(str, '.All', index, 150));
|
||||||
|
if (index < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = PatcherUtils.replaceWith(str, index, '.All', '.Locked');
|
||||||
|
|
||||||
|
index = str.indexOf('"Guide_Achievements_Unlocked_Empty","Guide_Achievements_Locked_Empty"');
|
||||||
|
index >= 0 && (index = PatcherUtils.indexOf(str, '.All', index, 250));
|
||||||
|
if (index < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = PatcherUtils.replaceWith(str, index, '.All', '.Locked');
|
||||||
|
return str;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let PATCH_ORDERS: PatchArray = [
|
let PATCH_ORDERS: PatchArray = [
|
||||||
@ -933,6 +972,8 @@ let PATCH_ORDERS: PatchArray = [
|
|||||||
'exposeStreamSession',
|
'exposeStreamSession',
|
||||||
'exposeDialogRoutes',
|
'exposeDialogRoutes',
|
||||||
|
|
||||||
|
'guideAchievementsDefaultLocked',
|
||||||
|
|
||||||
'enableTvRoutes',
|
'enableTvRoutes',
|
||||||
AppInterface && 'detectProductDetailsPage',
|
AppInterface && 'detectProductDetailsPage',
|
||||||
|
|
||||||
@ -962,6 +1003,7 @@ let PATCH_ORDERS: PatchArray = [
|
|||||||
'remotePlayKeepAlive',
|
'remotePlayKeepAlive',
|
||||||
'remotePlayDirectConnectUrl',
|
'remotePlayDirectConnectUrl',
|
||||||
'remotePlayDisableAchievementToast',
|
'remotePlayDisableAchievementToast',
|
||||||
|
'remotePlayRecentlyUsedTitleIds',
|
||||||
STATES.userAgent.capabilities.touch && 'patchUpdateInputConfigurationAsync',
|
STATES.userAgent.capabilities.touch && 'patchUpdateInputConfigurationAsync',
|
||||||
] : []),
|
] : []),
|
||||||
|
|
||||||
|
232
src/modules/remote-play-manager.ts
Normal file
232
src/modules/remote-play-manager.ts
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
import { STATES, AppInterface } from "@utils/global";
|
||||||
|
import { Toast } from "@utils/toast";
|
||||||
|
import { BxEvent } from "@utils/bx-event";
|
||||||
|
import { t } from "@utils/translation";
|
||||||
|
import { localRedirect } from "@modules/ui/ui";
|
||||||
|
import { BxLogger } from "@utils/bx-logger";
|
||||||
|
import { HeaderSection } from "./ui/header";
|
||||||
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
|
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||||
|
import { RemotePlayNavigationDialog } from "./ui/dialog/remote-play-dialog";
|
||||||
|
|
||||||
|
const LOG_TAG = 'RemotePlay';
|
||||||
|
|
||||||
|
export const enum RemotePlayConsoleState {
|
||||||
|
ON = 'On',
|
||||||
|
OFF = 'Off',
|
||||||
|
STANDBY = 'ConnectedStandby',
|
||||||
|
UNKNOWN = 'Unknown',
|
||||||
|
}
|
||||||
|
|
||||||
|
type RemotePlayRegion = {
|
||||||
|
name: string;
|
||||||
|
baseUri: string;
|
||||||
|
isDefault: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type RemotePlayConsole = {
|
||||||
|
deviceName: string;
|
||||||
|
serverId: string;
|
||||||
|
powerState: RemotePlayConsoleState;
|
||||||
|
consoleType: string;
|
||||||
|
// playPath: string;
|
||||||
|
// outOfHomeWarning: string;
|
||||||
|
// wirelessWarning: string;
|
||||||
|
// isDevKit: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export class RemotePlayManager {
|
||||||
|
private static instance: RemotePlayManager;
|
||||||
|
public static getInstance(): RemotePlayManager {
|
||||||
|
if (!this.instance) {
|
||||||
|
this.instance = new RemotePlayManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private isInitialized = false;
|
||||||
|
|
||||||
|
private XCLOUD_TOKEN!: string;
|
||||||
|
private XHOME_TOKEN!: string;
|
||||||
|
|
||||||
|
private consoles!: Array<RemotePlayConsole>;
|
||||||
|
private regions: Array<RemotePlayRegion> = [];
|
||||||
|
|
||||||
|
initialize() {
|
||||||
|
if (this.isInitialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isInitialized = true;
|
||||||
|
|
||||||
|
this.getXhomeToken(() => {
|
||||||
|
this.getConsolesList(() => {
|
||||||
|
BxLogger.info(LOG_TAG, 'Consoles', this.consoles);
|
||||||
|
|
||||||
|
STATES.supportedRegion && HeaderSection.showRemotePlayButton();
|
||||||
|
BxEvent.dispatch(window, BxEvent.REMOTE_PLAY_READY);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get xcloudToken() {
|
||||||
|
return this.XCLOUD_TOKEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
set xcloudToken(token: string) {
|
||||||
|
this.XCLOUD_TOKEN = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
get xhomeToken() {
|
||||||
|
return this.XHOME_TOKEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
getConsoles() {
|
||||||
|
return this.consoles;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private getXhomeToken(callback: any) {
|
||||||
|
if (this.XHOME_TOKEN) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let GSSV_TOKEN;
|
||||||
|
try {
|
||||||
|
GSSV_TOKEN = JSON.parse(localStorage.getItem('xboxcom_xbl_user_info')!).tokens['http://gssv.xboxlive.com/'].token;
|
||||||
|
} catch (e) {
|
||||||
|
for (let i = 0; i < localStorage.length; i++){
|
||||||
|
const key = localStorage.key(i)!;
|
||||||
|
if (!key.startsWith('Auth.User.')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = JSON.parse(localStorage.getItem(key)!);
|
||||||
|
for (const token of json.tokens) {
|
||||||
|
if (!token.relyingParty.includes('gssv.xboxlive.com')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSSV_TOKEN = token.tokenData.token;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const request = new Request('https://xhome.gssv-play-prod.xboxlive.com/v2/login/user', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
offeringId: 'xhome',
|
||||||
|
token: GSSV_TOKEN,
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fetch(request).then(resp => resp.json())
|
||||||
|
.then(json => {
|
||||||
|
this.regions = json.offeringSettings.regions;
|
||||||
|
this.XHOME_TOKEN = json.gsToken;
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getConsolesList(callback: any) {
|
||||||
|
if (this.consoles) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${this.XHOME_TOKEN}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test servers one by one
|
||||||
|
for (const region of this.regions) {
|
||||||
|
try {
|
||||||
|
const request = new Request(`${region.baseUri}/v6/servers/home?mr=50`, options);
|
||||||
|
const resp = await fetch(request);
|
||||||
|
|
||||||
|
const json = await resp.json();
|
||||||
|
if (json.results.length === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.consoles = json.results;
|
||||||
|
|
||||||
|
// Store working server
|
||||||
|
STATES.remotePlay.server = region.baseUri;
|
||||||
|
|
||||||
|
break;
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// None of the servers worked
|
||||||
|
if (!STATES.remotePlay.server) {
|
||||||
|
this.consoles = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
play(serverId: string, resolution?: string) {
|
||||||
|
if (resolution) {
|
||||||
|
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, resolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATES.remotePlay.config = {
|
||||||
|
serverId: serverId,
|
||||||
|
};
|
||||||
|
window.BX_REMOTE_PLAY_CONFIG = STATES.remotePlay.config;
|
||||||
|
|
||||||
|
localRedirect('/launch/fortnite/BT5P2X999VH2#remote-play');
|
||||||
|
}
|
||||||
|
|
||||||
|
togglePopup(force = null) {
|
||||||
|
if (!this.isReady()) {
|
||||||
|
Toast.show(t('getting-consoles-list'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.consoles.length === 0) {
|
||||||
|
Toast.show(t('no-consoles-found'), '', {instant: true});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show native dialog in Android app
|
||||||
|
if (AppInterface && AppInterface.showRemotePlayDialog) {
|
||||||
|
AppInterface.showRemotePlayDialog(JSON.stringify(this.consoles));
|
||||||
|
(document.activeElement as HTMLElement).blur();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemotePlayNavigationDialog.getInstance().show();
|
||||||
|
}
|
||||||
|
|
||||||
|
static detect() {
|
||||||
|
if (!getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATES.remotePlay.isPlaying = window.location.pathname.includes('/launch/') && window.location.hash.startsWith('#remote-play');
|
||||||
|
if (STATES.remotePlay?.isPlaying) {
|
||||||
|
window.BX_REMOTE_PLAY_CONFIG = STATES.remotePlay.config;
|
||||||
|
// Remove /launch/... from URL
|
||||||
|
window.history.replaceState({origin: 'better-xcloud'}, '', 'https://www.xbox.com/' + location.pathname.substring(1, 6) + '/play');
|
||||||
|
} else {
|
||||||
|
window.BX_REMOTE_PLAY_CONFIG = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isReady() {
|
||||||
|
return this.consoles !== null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,364 +0,0 @@
|
|||||||
import { STATES, AppInterface } from "@utils/global";
|
|
||||||
import { CE, createButton, ButtonStyle } from "@utils/html";
|
|
||||||
import { BxIcon } from "@utils/bx-icon";
|
|
||||||
import { Toast } from "@utils/toast";
|
|
||||||
import { BxEvent } from "@utils/bx-event";
|
|
||||||
import { t } from "@utils/translation";
|
|
||||||
import { localRedirect } from "@modules/ui/ui";
|
|
||||||
import { BxLogger } from "@utils/bx-logger";
|
|
||||||
import { HeaderSection } from "./ui/header";
|
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
|
||||||
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
|
||||||
|
|
||||||
const LOG_TAG = 'RemotePlay';
|
|
||||||
|
|
||||||
const enum RemotePlayConsoleState {
|
|
||||||
ON = 'On',
|
|
||||||
OFF = 'Off',
|
|
||||||
STANDBY = 'ConnectedStandby',
|
|
||||||
UNKNOWN = 'Unknown',
|
|
||||||
}
|
|
||||||
|
|
||||||
type RemotePlayRegion = {
|
|
||||||
name: string;
|
|
||||||
baseUri: string;
|
|
||||||
isDefault: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
type RemotePlayConsole = {
|
|
||||||
deviceName: string;
|
|
||||||
serverId: string;
|
|
||||||
powerState: RemotePlayConsoleState;
|
|
||||||
consoleType: string;
|
|
||||||
// playPath: string;
|
|
||||||
// outOfHomeWarning: string;
|
|
||||||
// wirelessWarning: string;
|
|
||||||
// isDevKit: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class RemotePlay {
|
|
||||||
static XCLOUD_TOKEN: string;
|
|
||||||
static XHOME_TOKEN: string;
|
|
||||||
static #CONSOLES: Array<RemotePlayConsole>;
|
|
||||||
static #REGIONS: Array<RemotePlayRegion>;
|
|
||||||
|
|
||||||
static readonly #STATE_LABELS: {[key in RemotePlayConsoleState]: string} = {
|
|
||||||
[RemotePlayConsoleState.ON]: t('powered-on'),
|
|
||||||
[RemotePlayConsoleState.OFF]: t('powered-off'),
|
|
||||||
[RemotePlayConsoleState.STANDBY]: t('standby'),
|
|
||||||
[RemotePlayConsoleState.UNKNOWN]: t('unknown'),
|
|
||||||
};
|
|
||||||
|
|
||||||
static readonly BASE_DEVICE_INFO = {
|
|
||||||
appInfo: {
|
|
||||||
env: {
|
|
||||||
clientAppId: window.location.host,
|
|
||||||
clientAppType: 'browser',
|
|
||||||
clientAppVersion: '24.17.36',
|
|
||||||
clientSdkVersion: '10.1.14',
|
|
||||||
httpEnvironment: 'prod',
|
|
||||||
sdkInstallId: '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dev: {
|
|
||||||
displayInfo: {
|
|
||||||
dimensions: {
|
|
||||||
widthInPixels: 1920,
|
|
||||||
heightInPixels: 1080,
|
|
||||||
},
|
|
||||||
pixelDensity: {
|
|
||||||
dpiX: 1,
|
|
||||||
dpiY: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
hw: {
|
|
||||||
make: 'Microsoft',
|
|
||||||
model: 'unknown',
|
|
||||||
sdktype: 'web',
|
|
||||||
},
|
|
||||||
os: {
|
|
||||||
name: 'windows',
|
|
||||||
ver: '22631.2715',
|
|
||||||
platform: 'desktop',
|
|
||||||
},
|
|
||||||
browser: {
|
|
||||||
browserName: 'chrome',
|
|
||||||
browserVersion: '125.0',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static #$content: HTMLElement;
|
|
||||||
|
|
||||||
static #initialize() {
|
|
||||||
if (RemotePlay.#$content) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemotePlay.#$content = CE('div', {}, t('getting-consoles-list'));
|
|
||||||
RemotePlay.#getXhomeToken(() => {
|
|
||||||
RemotePlay.#getConsolesList(() => {
|
|
||||||
BxLogger.info(LOG_TAG, 'Consoles', RemotePlay.#CONSOLES);
|
|
||||||
if (RemotePlay.#CONSOLES && RemotePlay.#CONSOLES.length > 0) {
|
|
||||||
STATES.supportedRegion && HeaderSection.showRemotePlayButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
RemotePlay.#renderConsoles();
|
|
||||||
BxEvent.dispatch(window, BxEvent.REMOTE_PLAY_READY);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static #renderConsoles() {
|
|
||||||
const $fragment = CE('div', {'class': 'bx-remote-play-container'});
|
|
||||||
|
|
||||||
if (!RemotePlay.#CONSOLES || RemotePlay.#CONSOLES.length === 0) {
|
|
||||||
$fragment.appendChild(CE('span', {}, t('no-consoles-found')));
|
|
||||||
RemotePlay.#$content = CE('div', {}, $fragment);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const $settingNote = CE('p', {});
|
|
||||||
|
|
||||||
const resolutions = [1080, 720];
|
|
||||||
const currentResolution = getPref(PrefKey.REMOTE_PLAY_RESOLUTION);
|
|
||||||
const $resolutionGroup = CE('div', {});
|
|
||||||
for (const resolution of resolutions) {
|
|
||||||
const value = `${resolution}p`;
|
|
||||||
const id = `bx_radio_xhome_resolution_${resolution}`;
|
|
||||||
|
|
||||||
const $radio = CE<HTMLInputElement>('input', {
|
|
||||||
'type': 'radio',
|
|
||||||
'value': value,
|
|
||||||
'id': id,
|
|
||||||
'name': 'bx_radio_xhome_resolution',
|
|
||||||
}, value);
|
|
||||||
|
|
||||||
$radio.addEventListener('change', e => {
|
|
||||||
const value = (e.target as HTMLInputElement).value;
|
|
||||||
|
|
||||||
$settingNote.textContent = value === '1080p' ? '✅ ' + t('can-stream-xbox-360-games') : '❌ ' + t('cant-stream-xbox-360-games');
|
|
||||||
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const $label = CE('label', {
|
|
||||||
'for': id,
|
|
||||||
'class': 'bx-remote-play-resolution',
|
|
||||||
}, $radio, `${resolution}p`);
|
|
||||||
|
|
||||||
$resolutionGroup.appendChild($label);
|
|
||||||
|
|
||||||
if (currentResolution === value) {
|
|
||||||
$radio.checked = true;
|
|
||||||
$radio.dispatchEvent(new Event('change'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const $qualitySettings = CE('div', {'class': 'bx-remote-play-settings'},
|
|
||||||
CE('div', {},
|
|
||||||
CE('label', {}, t('target-resolution'), $settingNote),
|
|
||||||
$resolutionGroup,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$fragment.appendChild($qualitySettings);
|
|
||||||
|
|
||||||
// Render concoles list
|
|
||||||
for (let con of RemotePlay.#CONSOLES) {
|
|
||||||
const $child = CE('div', {'class': 'bx-remote-play-device-wrapper'},
|
|
||||||
CE('div', {'class': 'bx-remote-play-device-info'},
|
|
||||||
CE('div', {},
|
|
||||||
CE('span', {'class': 'bx-remote-play-device-name'}, con.deviceName),
|
|
||||||
CE('span', {'class': 'bx-remote-play-console-type'}, con.consoleType.replace('Xbox', ''))
|
|
||||||
),
|
|
||||||
CE('div', {'class': 'bx-remote-play-power-state'}, RemotePlay.#STATE_LABELS[con.powerState]),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Connect button
|
|
||||||
createButton({
|
|
||||||
classes: ['bx-remote-play-connect-button'],
|
|
||||||
label: t('console-connect'),
|
|
||||||
style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE,
|
|
||||||
onClick: e => {
|
|
||||||
RemotePlay.play(con.serverId);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
$fragment.appendChild($child);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add Help button
|
|
||||||
$fragment.appendChild(createButton({
|
|
||||||
icon: BxIcon.QUESTION,
|
|
||||||
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE,
|
|
||||||
url: 'https://better-xcloud.github.io/remote-play',
|
|
||||||
label: t('help'),
|
|
||||||
}));
|
|
||||||
|
|
||||||
RemotePlay.#$content = CE('div', {}, $fragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
static #getXhomeToken(callback: any) {
|
|
||||||
if (RemotePlay.XHOME_TOKEN) {
|
|
||||||
callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let GSSV_TOKEN;
|
|
||||||
try {
|
|
||||||
GSSV_TOKEN = JSON.parse(localStorage.getItem('xboxcom_xbl_user_info')!).tokens['http://gssv.xboxlive.com/'].token;
|
|
||||||
} catch (e) {
|
|
||||||
for (let i = 0; i < localStorage.length; i++){
|
|
||||||
const key = localStorage.key(i)!;
|
|
||||||
if (!key.startsWith('Auth.User.')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const json = JSON.parse(localStorage.getItem(key)!);
|
|
||||||
for (const token of json.tokens) {
|
|
||||||
if (!token.relyingParty.includes('gssv.xboxlive.com')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
GSSV_TOKEN = token.tokenData.token;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const request = new Request('https://xhome.gssv-play-prod.xboxlive.com/v2/login/user', {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({
|
|
||||||
offeringId: 'xhome',
|
|
||||||
token: GSSV_TOKEN,
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json; charset=utf-8',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
fetch(request).then(resp => resp.json())
|
|
||||||
.then(json => {
|
|
||||||
RemotePlay.#REGIONS = json.offeringSettings.regions;
|
|
||||||
RemotePlay.XHOME_TOKEN = json.gsToken;
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static async #getConsolesList(callback: any) {
|
|
||||||
if (RemotePlay.#CONSOLES) {
|
|
||||||
callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
'Authorization': `Bearer ${RemotePlay.XHOME_TOKEN}`,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Test servers one by one
|
|
||||||
for (const region of RemotePlay.#REGIONS) {
|
|
||||||
try {
|
|
||||||
const request = new Request(`${region.baseUri}/v6/servers/home?mr=50`, options);
|
|
||||||
const resp = await fetch(request);
|
|
||||||
|
|
||||||
const json = await resp.json();
|
|
||||||
RemotePlay.#CONSOLES = json.results;
|
|
||||||
|
|
||||||
// Store working server
|
|
||||||
STATES.remotePlay.server = region.baseUri;
|
|
||||||
|
|
||||||
callback();
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
if (RemotePlay.#CONSOLES) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// None of the servers worked
|
|
||||||
if (!STATES.remotePlay.server) {
|
|
||||||
RemotePlay.#CONSOLES = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static play(serverId: string, resolution?: string) {
|
|
||||||
if (resolution) {
|
|
||||||
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, resolution);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATES.remotePlay.config = {
|
|
||||||
serverId: serverId,
|
|
||||||
};
|
|
||||||
window.BX_REMOTE_PLAY_CONFIG = STATES.remotePlay.config;
|
|
||||||
|
|
||||||
localRedirect('/launch/fortnite/BT5P2X999VH2#remote-play');
|
|
||||||
RemotePlay.detachPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
static preload() {
|
|
||||||
RemotePlay.#initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
static detachPopup() {
|
|
||||||
// Detach popup from body
|
|
||||||
const $popup = document.querySelector('.bx-remote-play-popup');
|
|
||||||
$popup && $popup.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
static togglePopup(force = null) {
|
|
||||||
if (!getPref(PrefKey.REMOTE_PLAY_ENABLED) || !RemotePlay.isReady()) {
|
|
||||||
Toast.show(t('getting-consoles-list'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemotePlay.#initialize();
|
|
||||||
|
|
||||||
if (AppInterface && AppInterface.showRemotePlayDialog) {
|
|
||||||
AppInterface.showRemotePlayDialog(JSON.stringify(RemotePlay.#CONSOLES));
|
|
||||||
(document.activeElement as HTMLElement).blur();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.querySelector('.bx-remote-play-popup')) {
|
|
||||||
if (force === false) {
|
|
||||||
RemotePlay.#$content.classList.add('bx-gone');
|
|
||||||
} else {
|
|
||||||
RemotePlay.#$content.classList.toggle('bx-gone');
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const $header = document.querySelector('#gamepass-root header')!;
|
|
||||||
|
|
||||||
const group = $header.firstElementChild!.getAttribute('data-group')!;
|
|
||||||
RemotePlay.#$content.setAttribute('data-group', group);
|
|
||||||
RemotePlay.#$content.classList.add('bx-remote-play-popup');
|
|
||||||
RemotePlay.#$content.classList.remove('bx-gone');
|
|
||||||
|
|
||||||
$header.insertAdjacentElement('afterend', RemotePlay.#$content);
|
|
||||||
}
|
|
||||||
|
|
||||||
static detect() {
|
|
||||||
if (!getPref(PrefKey.REMOTE_PLAY_ENABLED)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATES.remotePlay.isPlaying = window.location.pathname.includes('/launch/') && window.location.hash.startsWith('#remote-play');
|
|
||||||
if (STATES.remotePlay?.isPlaying) {
|
|
||||||
window.BX_REMOTE_PLAY_CONFIG = STATES.remotePlay.config;
|
|
||||||
// Remove /launch/... from URL
|
|
||||||
window.history.replaceState({origin: 'better-xcloud'}, '', 'https://www.xbox.com/' + location.pathname.substring(1, 6) + '/play');
|
|
||||||
} else {
|
|
||||||
window.BX_REMOTE_PLAY_CONFIG = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static isReady() {
|
|
||||||
return RemotePlay.#CONSOLES !== null && RemotePlay.#CONSOLES.length > 0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -80,7 +80,7 @@ export abstract class NavigationDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleGamepad(button: GamepadKey): boolean {
|
handleGamepad(button: GamepadKey): boolean {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
148
src/modules/ui/dialog/remote-play-dialog.ts
Normal file
148
src/modules/ui/dialog/remote-play-dialog.ts
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
import { ButtonStyle, CE, createButton } from "@/utils/html";
|
||||||
|
import { NavigationDialog } from "./navigation-dialog";
|
||||||
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
|
import { BxIcon } from "@/utils/bx-icon";
|
||||||
|
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
|
||||||
|
import { t } from "@/utils/translation";
|
||||||
|
import { RemotePlayConsoleState, RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
|
|
||||||
|
|
||||||
|
export class RemotePlayNavigationDialog extends NavigationDialog {
|
||||||
|
private static instance: RemotePlayNavigationDialog;
|
||||||
|
public static getInstance(): RemotePlayNavigationDialog {
|
||||||
|
if (!RemotePlayNavigationDialog.instance) {
|
||||||
|
RemotePlayNavigationDialog.instance = new RemotePlayNavigationDialog();
|
||||||
|
}
|
||||||
|
return RemotePlayNavigationDialog.instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly STATE_LABELS: Record<RemotePlayConsoleState, string> = {
|
||||||
|
[RemotePlayConsoleState.ON]: t('powered-on'),
|
||||||
|
[RemotePlayConsoleState.OFF]: t('powered-off'),
|
||||||
|
[RemotePlayConsoleState.STANDBY]: t('standby'),
|
||||||
|
[RemotePlayConsoleState.UNKNOWN]: t('unknown'),
|
||||||
|
};
|
||||||
|
|
||||||
|
$container!: HTMLElement;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.setupDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private setupDialog() {
|
||||||
|
const $fragment = CE('div', {'class': 'bx-remote-play-container'});
|
||||||
|
|
||||||
|
const $settingNote = CE('p', {});
|
||||||
|
|
||||||
|
const resolutions = [1080, 720];
|
||||||
|
const currentResolution = getPref(PrefKey.REMOTE_PLAY_RESOLUTION);
|
||||||
|
const $resolutionGroup = CE('div', {});
|
||||||
|
|
||||||
|
const onResolutionChange = (e: Event) => {
|
||||||
|
const value = (e.target as HTMLInputElement).value;
|
||||||
|
|
||||||
|
$settingNote.textContent = value === '1080p' ? '✅ ' + t('can-stream-xbox-360-games') : '❌ ' + t('cant-stream-xbox-360-games');
|
||||||
|
setPref(PrefKey.REMOTE_PLAY_RESOLUTION, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const resolution of resolutions) {
|
||||||
|
const value = `${resolution}p`;
|
||||||
|
const id = `bx_radio_xhome_resolution_${resolution}`;
|
||||||
|
|
||||||
|
const $radio = CE<HTMLInputElement>('input', {
|
||||||
|
type: 'radio',
|
||||||
|
value: value,
|
||||||
|
id: id,
|
||||||
|
name: 'bx_radio_xhome_resolution',
|
||||||
|
}, value);
|
||||||
|
|
||||||
|
$radio.addEventListener('input', onResolutionChange);
|
||||||
|
|
||||||
|
const $label = CE('label', {
|
||||||
|
for: id,
|
||||||
|
class: 'bx-remote-play-resolution',
|
||||||
|
}, $radio, `${resolution}p`);
|
||||||
|
|
||||||
|
$resolutionGroup.appendChild($label);
|
||||||
|
|
||||||
|
if (currentResolution === value) {
|
||||||
|
$radio.checked = true;
|
||||||
|
$radio.dispatchEvent(new Event('input'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const $qualitySettings = CE('div', {
|
||||||
|
class: 'bx-remote-play-settings',
|
||||||
|
}, CE('div', {},
|
||||||
|
CE('label', {}, t('target-resolution'), $settingNote),
|
||||||
|
$resolutionGroup,
|
||||||
|
));
|
||||||
|
|
||||||
|
$fragment.appendChild($qualitySettings);
|
||||||
|
|
||||||
|
// Render consoles list
|
||||||
|
const manager = RemotePlayManager.getInstance();
|
||||||
|
const consoles = manager.getConsoles();
|
||||||
|
|
||||||
|
for (let con of consoles) {
|
||||||
|
const $child = CE('div', {class: 'bx-remote-play-device-wrapper'},
|
||||||
|
CE('div', {class: 'bx-remote-play-device-info'},
|
||||||
|
CE('div', {},
|
||||||
|
CE('span', {class: 'bx-remote-play-device-name'}, con.deviceName),
|
||||||
|
CE('span', {class: 'bx-remote-play-console-type'}, con.consoleType.replace('Xbox', ''))
|
||||||
|
),
|
||||||
|
CE('div', {class: 'bx-remote-play-power-state'}, this.STATE_LABELS[con.powerState]),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Connect button
|
||||||
|
createButton({
|
||||||
|
classes: ['bx-remote-play-connect-button'],
|
||||||
|
label: t('console-connect'),
|
||||||
|
style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE,
|
||||||
|
onClick: e => manager.play(con.serverId),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
$fragment.appendChild($child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add buttons
|
||||||
|
$fragment.appendChild(
|
||||||
|
CE('div', {
|
||||||
|
class: 'bx-remote-play-buttons',
|
||||||
|
_nearby: {
|
||||||
|
orientation: 'horizontal',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
createButton({
|
||||||
|
icon: BxIcon.QUESTION,
|
||||||
|
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE,
|
||||||
|
url: 'https://better-xcloud.github.io/remote-play',
|
||||||
|
label: t('help'),
|
||||||
|
}),
|
||||||
|
|
||||||
|
createButton({
|
||||||
|
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE,
|
||||||
|
label: t('close'),
|
||||||
|
onClick: e => this.hide(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
this.$container = $fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDialog(): NavigationDialog {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
getContent(): HTMLElement {
|
||||||
|
return this.$container;
|
||||||
|
}
|
||||||
|
|
||||||
|
focusIfNeeded(): void {
|
||||||
|
const $btnConnect = this.$container.querySelector('.bx-remote-play-device-wrapper button') as HTMLElement;
|
||||||
|
$btnConnect && $btnConnect.focus();
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { onChangeVideoPlayerType, updateVideoPlayer } from "@/modules/stream/stream-settings-utils";
|
import { onChangeVideoPlayerType, updateVideoPlayer } from "@/modules/stream/stream-settings-utils";
|
||||||
import { ButtonStyle, CE, createButton, createSvgIcon, removeChildElements } from "@/utils/html";
|
import { ButtonStyle, CE, createButton, createSvgIcon, removeChildElements, type BxButton } from "@/utils/html";
|
||||||
import { NavigationDialog, NavigationDirection } from "./navigation-dialog";
|
import { NavigationDialog, NavigationDirection } from "./navigation-dialog";
|
||||||
import { ControllerShortcut } from "@/modules/controller-shortcut";
|
import { ControllerShortcut } from "@/modules/controller-shortcut";
|
||||||
import { MkbRemapper } from "@/modules/mkb/mkb-remapper";
|
import { MkbRemapper } from "@/modules/mkb/mkb-remapper";
|
||||||
@ -97,12 +97,19 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
|||||||
|
|
||||||
// "New version available" button
|
// "New version available" button
|
||||||
if (!SCRIPT_VERSION.includes('beta') && PREF_LATEST_VERSION && PREF_LATEST_VERSION != SCRIPT_VERSION) {
|
if (!SCRIPT_VERSION.includes('beta') && PREF_LATEST_VERSION && PREF_LATEST_VERSION != SCRIPT_VERSION) {
|
||||||
// Show new version indicator
|
// Show new version button
|
||||||
topButtons.push(createButton({
|
const opts = {
|
||||||
label: `🌟 Version ${PREF_LATEST_VERSION} available`,
|
label: '🌟 ' + t('new-version-available', {version: PREF_LATEST_VERSION}),
|
||||||
style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE | ButtonStyle.FULL_WIDTH,
|
style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE | ButtonStyle.FULL_WIDTH,
|
||||||
url: 'https://github.com/redphx/better-xcloud/releases/latest',
|
} as BxButton;
|
||||||
}));
|
|
||||||
|
if (AppInterface && AppInterface.updateLatestScript) {
|
||||||
|
opts.onClick = e => AppInterface.updateLatestScript();
|
||||||
|
} else {
|
||||||
|
opts.url = 'https://github.com/redphx/better-xcloud/releases/latest';
|
||||||
|
}
|
||||||
|
|
||||||
|
topButtons.push(createButton(opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buttons for Android app
|
// Buttons for Android app
|
||||||
|
@ -2,7 +2,7 @@ import { SCRIPT_VERSION } from "@utils/global";
|
|||||||
import { createButton, ButtonStyle, CE, isElementVisible } from "@utils/html";
|
import { createButton, ButtonStyle, CE, isElementVisible } from "@utils/html";
|
||||||
import { BxIcon } from "@utils/bx-icon";
|
import { BxIcon } from "@utils/bx-icon";
|
||||||
import { getPreferredServerRegion } from "@utils/region";
|
import { getPreferredServerRegion } from "@utils/region";
|
||||||
import { RemotePlay } from "@modules/remote-play";
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
import { t } from "@utils/translation";
|
import { t } from "@utils/translation";
|
||||||
import { SettingsNavigationDialog } from "./dialog/settings-dialog";
|
import { SettingsNavigationDialog } from "./dialog/settings-dialog";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
@ -15,7 +15,7 @@ export class HeaderSection {
|
|||||||
title: t('remote-play'),
|
title: t('remote-play'),
|
||||||
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE | ButtonStyle.CIRCULAR,
|
style: ButtonStyle.GHOST | ButtonStyle.FOCUSABLE | ButtonStyle.CIRCULAR,
|
||||||
onClick: e => {
|
onClick: e => {
|
||||||
RemotePlay.togglePopup();
|
RemotePlayManager.getInstance().togglePopup();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { BxEvent } from "@utils/bx-event";
|
import { BxEvent } from "@utils/bx-event";
|
||||||
import { LoadingScreen } from "@modules/loading-screen";
|
import { LoadingScreen } from "@modules/loading-screen";
|
||||||
import { RemotePlay } from "@modules/remote-play";
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
import { HeaderSection } from "@/modules/ui/header";
|
import { HeaderSection } from "@/modules/ui/header";
|
||||||
import { NavigationDialogManager } from "@/modules/ui/dialog/navigation-dialog";
|
import { NavigationDialogManager } from "@/modules/ui/dialog/navigation-dialog";
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ export function onHistoryChanged(e: PopStateEvent) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setTimeout(RemotePlay.detect, 10);
|
window.setTimeout(RemotePlayManager.detect, 10);
|
||||||
|
|
||||||
// Hide Global settings
|
// Hide Global settings
|
||||||
const $settings = document.querySelector('.bx-settings-container');
|
const $settings = document.querySelector('.bx-settings-container');
|
||||||
@ -35,9 +35,6 @@ export function onHistoryChanged(e: PopStateEvent) {
|
|||||||
// Hide Navigation dialog
|
// Hide Navigation dialog
|
||||||
NavigationDialogManager.getInstance().hide();
|
NavigationDialogManager.getInstance().hide();
|
||||||
|
|
||||||
// Hide Remote Play popup
|
|
||||||
RemotePlay.detachPopup();
|
|
||||||
|
|
||||||
LoadingScreen.reset();
|
LoadingScreen.reset();
|
||||||
window.setTimeout(HeaderSection.watchHeader, 2000);
|
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ const ButtonStyleClass = {
|
|||||||
[ButtonStyle.NORMAL_LINK]: 'bx-normal-link',
|
[ButtonStyle.NORMAL_LINK]: 'bx-normal-link',
|
||||||
}
|
}
|
||||||
|
|
||||||
type BxButton = {
|
export type BxButton = {
|
||||||
style?: ButtonStyle;
|
style?: ButtonStyle;
|
||||||
url?: string;
|
url?: string;
|
||||||
classes?: string[];
|
classes?: string[];
|
||||||
|
@ -254,6 +254,7 @@ export function patchPointerLockApi() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// const nativeRequestPointerLock = HTMLElement.prototype.requestPointerLock;
|
// const nativeRequestPointerLock = HTMLElement.prototype.requestPointerLock;
|
||||||
|
// @ts-ignore
|
||||||
HTMLElement.prototype.requestPointerLock = function() {
|
HTMLElement.prototype.requestPointerLock = function() {
|
||||||
pointerLockElement = document.documentElement;
|
pointerLockElement = document.documentElement;
|
||||||
window.dispatchEvent(new Event(BxEvent.POINTER_LOCK_REQUESTED));
|
window.dispatchEvent(new Event(BxEvent.POINTER_LOCK_REQUESTED));
|
||||||
|
@ -584,7 +584,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
|||||||
default: 'default',
|
default: 'default',
|
||||||
options: {
|
options: {
|
||||||
'default': t('default'),
|
'default': t('default'),
|
||||||
'low-power': t('low-power'),
|
'low-power': t('battery-saving'),
|
||||||
'high-performance': t('high-performance'),
|
'high-performance': t('high-performance'),
|
||||||
},
|
},
|
||||||
suggest: {
|
suggest: {
|
||||||
|
@ -47,6 +47,7 @@ const Texts = {
|
|||||||
"badge-playtime": "Playtime",
|
"badge-playtime": "Playtime",
|
||||||
"badge-server": "Server",
|
"badge-server": "Server",
|
||||||
"badge-video": "Video",
|
"badge-video": "Video",
|
||||||
|
"battery-saving": "Battery saving",
|
||||||
"better-xcloud": "Better xCloud",
|
"better-xcloud": "Better xCloud",
|
||||||
"bitrate-audio-maximum": "Maximum audio bitrate",
|
"bitrate-audio-maximum": "Maximum audio bitrate",
|
||||||
"bitrate-video-maximum": "Maximum video bitrate",
|
"bitrate-video-maximum": "Maximum video bitrate",
|
||||||
@ -142,7 +143,6 @@ const Texts = {
|
|||||||
"load-failed-message": "Failed to run Better xCloud",
|
"load-failed-message": "Failed to run Better xCloud",
|
||||||
"loading-screen": "Loading screen",
|
"loading-screen": "Loading screen",
|
||||||
"local-co-op": "Local co-op",
|
"local-co-op": "Local co-op",
|
||||||
"low-power": "Low power",
|
|
||||||
"lowest-quality": "Lowest quality",
|
"lowest-quality": "Lowest quality",
|
||||||
"map-mouse-to": "Map mouse to",
|
"map-mouse-to": "Map mouse to",
|
||||||
"may-not-work-properly": "May not work properly!",
|
"may-not-work-properly": "May not work properly!",
|
||||||
@ -157,6 +157,27 @@ const Texts = {
|
|||||||
"name": "Name",
|
"name": "Name",
|
||||||
"native-mkb": "Native Mouse & Keyboard",
|
"native-mkb": "Native Mouse & Keyboard",
|
||||||
"new": "New",
|
"new": "New",
|
||||||
|
"new-version-available": [
|
||||||
|
(e: any) => `Version ${e.version} available`,
|
||||||
|
,
|
||||||
|
,
|
||||||
|
(e: any) => `Version ${e.version} verfügbar`,
|
||||||
|
,
|
||||||
|
(e: any) => `Versión ${e.version} disponible`,
|
||||||
|
(e: any) => `Version ${e.version} disponible`,
|
||||||
|
(e: any) => `Disponibile la versione ${e.version}`,
|
||||||
|
(e: any) => `Ver ${e.version} が利用可能です`,
|
||||||
|
(e: any) => `${e.version} 버전 사용가능`,
|
||||||
|
(e: any) => `Dostępna jest nowa wersja ${e.version}`,
|
||||||
|
(e: any) => `Versão ${e.version} disponível`,
|
||||||
|
,
|
||||||
|
,
|
||||||
|
,
|
||||||
|
(e: any) => `Доступна версія ${e.version}`,
|
||||||
|
(e: any) => `Đã có phiên bản ${e.version}`,
|
||||||
|
(e: any) => `版本 ${e.version} 可供更新`,
|
||||||
|
(e: any) => `已可更新為 ${e.version} 版`,
|
||||||
|
],
|
||||||
"no-consoles-found": "No consoles found",
|
"no-consoles-found": "No consoles found",
|
||||||
"normal": "Normal",
|
"normal": "Normal",
|
||||||
"off": "Off",
|
"off": "Off",
|
||||||
@ -199,7 +220,7 @@ const Texts = {
|
|||||||
"recommended": "Recommended",
|
"recommended": "Recommended",
|
||||||
"recommended-settings-for-device": [
|
"recommended-settings-for-device": [
|
||||||
(e: any) => `Recommended settings for ${e.device}`,
|
(e: any) => `Recommended settings for ${e.device}`,
|
||||||
,
|
(e: any) => `Configuració recomanada per a ${e.device}`,
|
||||||
,
|
,
|
||||||
(e: any) => `Empfohlene Einstellungen für ${e.device}`,
|
(e: any) => `Empfohlene Einstellungen für ${e.device}`,
|
||||||
,
|
,
|
||||||
@ -209,7 +230,7 @@ const Texts = {
|
|||||||
(e: any) => `${e.device} の推奨設定`,
|
(e: any) => `${e.device} の推奨設定`,
|
||||||
(e: any) => `다음 기기에서 권장되는 설정: ${e.device}`,
|
(e: any) => `다음 기기에서 권장되는 설정: ${e.device}`,
|
||||||
(e: any) => `Zalecane ustawienia dla ${e.device}`,
|
(e: any) => `Zalecane ustawienia dla ${e.device}`,
|
||||||
,
|
(e: any) => `Configurações recomendadas para ${e.device}`,
|
||||||
(e: any) => `Рекомендуемые настройки для ${e.device}`,
|
(e: any) => `Рекомендуемые настройки для ${e.device}`,
|
||||||
,
|
,
|
||||||
(e: any) => `${e.device} için önerilen ayarlar`,
|
(e: any) => `${e.device} için önerilen ayarlar`,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { LoadingScreen } from "@modules/loading-screen";
|
import { LoadingScreen } from "@modules/loading-screen";
|
||||||
import { RemotePlay } from "@modules/remote-play";
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
import { StreamBadges } from "@modules/stream/stream-badges";
|
import { StreamBadges } from "@modules/stream/stream-badges";
|
||||||
import { TouchController } from "@modules/touch-controller";
|
import { TouchController } from "@modules/touch-controller";
|
||||||
import { BxEvent } from "./bx-event";
|
import { BxEvent } from "./bx-event";
|
||||||
@ -30,7 +30,7 @@ class XcloudInterceptor {
|
|||||||
const obj = await response.clone().json();
|
const obj = await response.clone().json();
|
||||||
|
|
||||||
// Store xCloud token
|
// Store xCloud token
|
||||||
RemotePlay.XCLOUD_TOKEN = obj.gsToken;
|
RemotePlayManager.getInstance().xcloudToken = obj.gsToken;
|
||||||
|
|
||||||
// Get server list
|
// Get server list
|
||||||
const serverEmojis = {
|
const serverEmojis = {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { RemotePlay } from "@/modules/remote-play";
|
|
||||||
import { TouchController } from "@/modules/touch-controller";
|
import { TouchController } from "@/modules/touch-controller";
|
||||||
import { BxEvent } from "./bx-event";
|
import { BxEvent } from "./bx-event";
|
||||||
import { SupportedInputType } from "./bx-exposed";
|
import { SupportedInputType } from "./bx-exposed";
|
||||||
@ -8,10 +7,51 @@ import { patchIceCandidates } from "./network";
|
|||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref, StreamResolution, StreamTouchController } from "./settings-storages/global-settings-storage";
|
import { getPref, StreamResolution, StreamTouchController } from "./settings-storages/global-settings-storage";
|
||||||
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||||
|
import { RemotePlayManager } from "@/modules/remote-play-manager";
|
||||||
|
|
||||||
export class XhomeInterceptor {
|
export class XhomeInterceptor {
|
||||||
static #consoleAddrs: RemotePlayConsoleAddresses = {};
|
static #consoleAddrs: RemotePlayConsoleAddresses = {};
|
||||||
|
|
||||||
|
private static readonly BASE_DEVICE_INFO = {
|
||||||
|
appInfo: {
|
||||||
|
env: {
|
||||||
|
clientAppId: window.location.host,
|
||||||
|
clientAppType: 'browser',
|
||||||
|
clientAppVersion: '24.17.36',
|
||||||
|
clientSdkVersion: '10.1.14',
|
||||||
|
httpEnvironment: 'prod',
|
||||||
|
sdkInstallId: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
dev: {
|
||||||
|
displayInfo: {
|
||||||
|
dimensions: {
|
||||||
|
widthInPixels: 1920,
|
||||||
|
heightInPixels: 1080,
|
||||||
|
},
|
||||||
|
pixelDensity: {
|
||||||
|
dpiX: 1,
|
||||||
|
dpiY: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
hw: {
|
||||||
|
make: 'Microsoft',
|
||||||
|
model: 'unknown',
|
||||||
|
sdktype: 'web',
|
||||||
|
},
|
||||||
|
os: {
|
||||||
|
name: 'windows',
|
||||||
|
ver: '22631.2715',
|
||||||
|
platform: 'desktop',
|
||||||
|
},
|
||||||
|
browser: {
|
||||||
|
browserName: 'chrome',
|
||||||
|
browserVersion: '125.0',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
static async #handleLogin(request: Request) {
|
static async #handleLogin(request: Request) {
|
||||||
try {
|
try {
|
||||||
const clone = (request as Request).clone();
|
const clone = (request as Request).clone();
|
||||||
@ -42,7 +82,7 @@ export class XhomeInterceptor {
|
|||||||
|
|
||||||
const processPorts = (port: number): number[] => {
|
const processPorts = (port: number): number[] => {
|
||||||
const ports = new Set<number>();
|
const ports = new Set<number>();
|
||||||
ports.add(port);
|
port && ports.add(port);
|
||||||
ports.add(9002);
|
ports.add(9002);
|
||||||
|
|
||||||
return Array.from(ports);
|
return Array.from(ports);
|
||||||
@ -111,7 +151,7 @@ export class XhomeInterceptor {
|
|||||||
for (const pair of (clone.headers as any).entries()) {
|
for (const pair of (clone.headers as any).entries()) {
|
||||||
headers[pair[0]] = pair[1];
|
headers[pair[0]] = pair[1];
|
||||||
}
|
}
|
||||||
headers.authorization = `Bearer ${RemotePlay.XCLOUD_TOKEN}`;
|
headers.authorization = `Bearer ${RemotePlayManager.getInstance().xcloudToken}`;
|
||||||
|
|
||||||
const index = request.url.indexOf('.xboxlive.com');
|
const index = request.url.indexOf('.xboxlive.com');
|
||||||
request = new Request('https://wus.core.gssv-play-prod' + request.url.substring(index), {
|
request = new Request('https://wus.core.gssv-play-prod' + request.url.substring(index), {
|
||||||
@ -146,10 +186,10 @@ export class XhomeInterceptor {
|
|||||||
headers[pair[0]] = pair[1];
|
headers[pair[0]] = pair[1];
|
||||||
}
|
}
|
||||||
// Add xHome token to headers
|
// Add xHome token to headers
|
||||||
headers.authorization = `Bearer ${RemotePlay.XHOME_TOKEN}`;
|
headers.authorization = `Bearer ${RemotePlayManager.getInstance().xhomeToken}`;
|
||||||
|
|
||||||
// Patch resolution
|
// Patch resolution
|
||||||
const deviceInfo = RemotePlay.BASE_DEVICE_INFO;
|
const deviceInfo = XhomeInterceptor.BASE_DEVICE_INFO;
|
||||||
if (getPref(PrefKey.REMOTE_PLAY_RESOLUTION) === StreamResolution.DIM_720P) {
|
if (getPref(PrefKey.REMOTE_PLAY_RESOLUTION) === StreamResolution.DIM_720P) {
|
||||||
deviceInfo.dev.os.name = 'android';
|
deviceInfo.dev.os.name = 'android';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user