mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Add generateMsDeviceInfo()
This commit is contained in:
parent
f7266d6361
commit
c426f64ea9
93
dist/better-xcloud.lite.user.js
vendored
93
dist/better-xcloud.lite.user.js
vendored
File diff suppressed because one or more lines are too long
146
dist/better-xcloud.user.js
vendored
146
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -40,6 +40,7 @@ export class RemotePlayDialog extends NavigationDialog {
|
|||||||
let $resolutions : HTMLSelectElement | NavigationElement = CE<HTMLSelectElement>('select', {},
|
let $resolutions : HTMLSelectElement | NavigationElement = CE<HTMLSelectElement>('select', {},
|
||||||
CE('option', { value: StreamResolution.DIM_720P }, '720p'),
|
CE('option', { value: StreamResolution.DIM_720P }, '720p'),
|
||||||
CE('option', { value: StreamResolution.DIM_1080P }, '1080p'),
|
CE('option', { value: StreamResolution.DIM_1080P }, '1080p'),
|
||||||
|
// CE('option', { value: StreamResolution.DIM_1080P_HQ }, `1080p (HQ) ${t('experimental')}`),
|
||||||
);
|
);
|
||||||
|
|
||||||
$resolutions = BxSelectElement.create($resolutions as HTMLSelectElement);
|
$resolutions = BxSelectElement.create($resolutions as HTMLSelectElement);
|
||||||
|
2
src/types/index.d.ts
vendored
2
src/types/index.d.ts
vendored
@ -162,3 +162,5 @@ type XboxAchievement = {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type OsName = 'windows' | 'tizen' | 'android';
|
||||||
|
@ -11,6 +11,7 @@ import { XcloudInterceptor } from "./xcloud-interceptor";
|
|||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref } from "./settings-storages/global-settings-storage";
|
import { getPref } from "./settings-storages/global-settings-storage";
|
||||||
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||||
|
import { StreamResolution } from "@/enums/pref-values";
|
||||||
|
|
||||||
type RequestType = 'xcloud' | 'xhome';
|
type RequestType = 'xcloud' | 'xhome';
|
||||||
|
|
||||||
@ -120,6 +121,7 @@ export async function patchIceCandidates(request: Request, consoleAddrs?: Remote
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function interceptHttpRequests() {
|
export function interceptHttpRequests() {
|
||||||
let BLOCKED_URLS: string[] = [];
|
let BLOCKED_URLS: string[] = [];
|
||||||
if (getPref(PrefKey.BLOCK_TRACKING)) {
|
if (getPref(PrefKey.BLOCK_TRACKING)) {
|
||||||
@ -283,3 +285,45 @@ export function interceptHttpRequests() {
|
|||||||
return XcloudInterceptor.handle(request, init);
|
return XcloudInterceptor.handle(request, init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function generateMsDeviceInfo(osName: OsName) {
|
||||||
|
return {
|
||||||
|
appInfo: {
|
||||||
|
env: {
|
||||||
|
clientAppId: window.location.host,
|
||||||
|
clientAppType: 'browser',
|
||||||
|
clientAppVersion: '26.1.97',
|
||||||
|
clientSdkVersion: '10.3.7',
|
||||||
|
httpEnvironment: 'prod',
|
||||||
|
sdkInstallId: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dev: {
|
||||||
|
os: { name: osName, ver: '22631.2715', platform: 'desktop' },
|
||||||
|
hw: { make: 'Microsoft', model: 'unknown', sdktype: 'web' },
|
||||||
|
browser: { browserName: 'chrome', browserVersion: '130.0' },
|
||||||
|
displayInfo: {
|
||||||
|
dimensions: { widthInPixels: 1920, heightInPixels: 1080 },
|
||||||
|
pixelDensity: { dpiX: 1, dpiY: 1 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getOsNameFromResolution(resolution: StreamResolution): OsName {
|
||||||
|
let osName: OsName;
|
||||||
|
switch (resolution) {
|
||||||
|
case StreamResolution.DIM_1080P_HQ:
|
||||||
|
osName = 'tizen';
|
||||||
|
break;
|
||||||
|
case StreamResolution.DIM_1080P:
|
||||||
|
osName = 'windows';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
osName = 'android';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return osName;
|
||||||
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { TouchController } from "@modules/touch-controller";
|
|||||||
import { BxEvent } from "./bx-event";
|
import { BxEvent } from "./bx-event";
|
||||||
import { NATIVE_FETCH, BX_FLAGS } from "./bx-flags";
|
import { NATIVE_FETCH, BX_FLAGS } from "./bx-flags";
|
||||||
import { STATES } from "./global";
|
import { STATES } from "./global";
|
||||||
import { patchIceCandidates } from "./network";
|
import { generateMsDeviceInfo, getOsNameFromResolution, patchIceCandidates } from "./network";
|
||||||
import { getPreferredServerRegion } from "./region";
|
import { getPreferredServerRegion } from "./region";
|
||||||
import { BypassServerIps } from "@/enums/bypass-servers";
|
import { BypassServerIps } from "@/enums/bypass-servers";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
@ -42,46 +42,6 @@ export class XcloudInterceptor {
|
|||||||
WestEurope: ['🇪🇺', 'europe'],
|
WestEurope: ['🇪🇺', 'europe'],
|
||||||
};
|
};
|
||||||
|
|
||||||
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',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
private static async handleLogin(request: RequestInfo | URL, init?: RequestInit) {
|
private static async handleLogin(request: RequestInfo | URL, init?: RequestInit) {
|
||||||
const bypassServer = getPref<string>(PrefKey.SERVER_BYPASS_RESTRICTION);
|
const bypassServer = getPref<string>(PrefKey.SERVER_BYPASS_RESTRICTION);
|
||||||
if (bypassServer !== 'off') {
|
if (bypassServer !== 'off') {
|
||||||
@ -175,24 +135,8 @@ export class XcloudInterceptor {
|
|||||||
|
|
||||||
// Force stream's resolution
|
// Force stream's resolution
|
||||||
if (PREF_STREAM_TARGET_RESOLUTION !== 'auto') {
|
if (PREF_STREAM_TARGET_RESOLUTION !== 'auto') {
|
||||||
let osName;
|
const osName = getOsNameFromResolution(PREF_STREAM_TARGET_RESOLUTION);
|
||||||
switch (PREF_STREAM_TARGET_RESOLUTION) {
|
headers['x-ms-device-info'] = JSON.stringify(generateMsDeviceInfo(osName));
|
||||||
case StreamResolution.DIM_1080P_HQ:
|
|
||||||
osName = 'tizen';
|
|
||||||
|
|
||||||
const deviceInfo = XcloudInterceptor.BASE_DEVICE_INFO;
|
|
||||||
deviceInfo.dev.os.name = 'tizen';
|
|
||||||
headers['x-ms-device-info'] = JSON.stringify(deviceInfo);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case StreamResolution.DIM_1080P:
|
|
||||||
osName = 'windows';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
osName = 'android';
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
body.settings.osName = osName;
|
body.settings.osName = osName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { BxEvent } from "./bx-event";
|
|||||||
import { SupportedInputType } from "./bx-exposed";
|
import { SupportedInputType } from "./bx-exposed";
|
||||||
import { NATIVE_FETCH } from "./bx-flags";
|
import { NATIVE_FETCH } from "./bx-flags";
|
||||||
import { STATES } from "./global";
|
import { STATES } from "./global";
|
||||||
import { patchIceCandidates } from "./network";
|
import { generateMsDeviceInfo, getOsNameFromResolution, patchIceCandidates } from "./network";
|
||||||
import { PrefKey } from "@/enums/pref-keys";
|
import { PrefKey } from "@/enums/pref-keys";
|
||||||
import { getPref } from "./settings-storages/global-settings-storage";
|
import { getPref } from "./settings-storages/global-settings-storage";
|
||||||
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||||
@ -13,46 +13,6 @@ import { StreamResolution, TouchControllerMode } from "@/enums/pref-values";
|
|||||||
export class XhomeInterceptor {
|
export class XhomeInterceptor {
|
||||||
private static consoleAddrs: RemotePlayConsoleAddresses = {};
|
private 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',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
private static async handleLogin(request: Request) {
|
private static async handleLogin(request: Request) {
|
||||||
try {
|
try {
|
||||||
const clone = request.clone();
|
const clone = request.clone();
|
||||||
@ -191,21 +151,8 @@ export class XhomeInterceptor {
|
|||||||
headers.authorization = `Bearer ${RemotePlayManager.getInstance()!.getXhomeToken()}`;
|
headers.authorization = `Bearer ${RemotePlayManager.getInstance()!.getXhomeToken()}`;
|
||||||
|
|
||||||
// Patch resolution
|
// Patch resolution
|
||||||
const deviceInfo = XhomeInterceptor.BASE_DEVICE_INFO;
|
const osName = getOsNameFromResolution(getPref<StreamResolution>(PrefKey.REMOTE_PLAY_STREAM_RESOLUTION));
|
||||||
const resolution = getPref<StreamResolution>(PrefKey.REMOTE_PLAY_STREAM_RESOLUTION);
|
headers['x-ms-device-info'] = JSON.stringify(generateMsDeviceInfo(osName));
|
||||||
switch (resolution) {
|
|
||||||
case StreamResolution.DIM_1080P_HQ:
|
|
||||||
deviceInfo.dev.os.name = 'tizen';
|
|
||||||
break;
|
|
||||||
case StreamResolution.DIM_720P:
|
|
||||||
deviceInfo.dev.os.name = 'android';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
deviceInfo.dev.os.name = 'windows';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
headers['x-ms-device-info'] = JSON.stringify(deviceInfo);
|
|
||||||
|
|
||||||
const opts: Record<string, any> = {
|
const opts: Record<string, any> = {
|
||||||
method: clone.method,
|
method: clone.method,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user