mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-28 18:31:44 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
e40d258c79 | |||
3864457a07 | |||
da362325f2 | |||
4062852904 | |||
c426f64ea9 |
99
dist/better-xcloud.lite.user.js
vendored
99
dist/better-xcloud.lite.user.js
vendored
File diff suppressed because one or more lines are too long
2
dist/better-xcloud.meta.js
vendored
2
dist/better-xcloud.meta.js
vendored
@ -1,5 +1,5 @@
|
||||
// ==UserScript==
|
||||
// @name Better xCloud
|
||||
// @namespace https://github.com/redphx
|
||||
// @version 6.0.1
|
||||
// @version 6.0.2
|
||||
// ==/UserScript==
|
||||
|
164
dist/better-xcloud.user.js
vendored
164
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -195,6 +195,8 @@ export class NativeMkbHandler extends MkbHandler {
|
||||
|
||||
destroy(): void {
|
||||
this.pointerClient?.stop();
|
||||
this.stop();
|
||||
|
||||
window.removeEventListener('keyup', this);
|
||||
|
||||
window.removeEventListener(BxEvent.XCLOUD_DIALOG_SHOWN, this);
|
||||
@ -203,6 +205,7 @@ export class NativeMkbHandler extends MkbHandler {
|
||||
window.removeEventListener(BxEvent.XCLOUD_POLLING_MODE_CHANGED, this);
|
||||
|
||||
this.waitForMouseData(false);
|
||||
document.pointerLockElement && document.exitPointerLock();
|
||||
}
|
||||
|
||||
handleMouseMove(data: MkbMouseMove): void {
|
||||
|
@ -947,12 +947,23 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
||||
streamPageBeforeLoad(str: string) {
|
||||
return PatcherUtils.patchBeforePageLoad(str, 'stream');
|
||||
},
|
||||
|
||||
disableAbsoluteMouse(str: string) {
|
||||
let text = 'sendAbsoluteMouseCapableMessage(e){';
|
||||
if (!str.includes(text)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
str = str.replace(text, text + 'return;');
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
let PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
...(getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||
...(AppInterface && getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||
'enableNativeMkb',
|
||||
'exposeInputSink',
|
||||
'disableAbsoluteMouse',
|
||||
] : []),
|
||||
|
||||
'modifyPreloadedState',
|
||||
@ -1062,7 +1073,7 @@ let STREAM_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||
] : []),
|
||||
|
||||
// Native MKB
|
||||
...(getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||
...(AppInterface && getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||
'patchMouseAndKeyboardEnabled',
|
||||
'disableNativeRequestPointerLock',
|
||||
] : []),
|
||||
|
@ -40,6 +40,7 @@ export class RemotePlayDialog extends NavigationDialog {
|
||||
let $resolutions : HTMLSelectElement | NavigationElement = CE<HTMLSelectElement>('select', {},
|
||||
CE('option', { value: StreamResolution.DIM_720P }, '720p'),
|
||||
CE('option', { value: StreamResolution.DIM_1080P }, '1080p'),
|
||||
// CE('option', { value: StreamResolution.DIM_1080P_HQ }, `1080p (HQ) ${t('experimental')}`),
|
||||
);
|
||||
|
||||
$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;
|
||||
}
|
||||
};
|
||||
|
||||
type OsName = 'windows' | 'tizen' | 'android';
|
||||
|
@ -11,6 +11,7 @@ import { XcloudInterceptor } from "./xcloud-interceptor";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||
import { StreamResolution } from "@/enums/pref-values";
|
||||
|
||||
type RequestType = 'xcloud' | 'xhome';
|
||||
|
||||
@ -120,6 +121,7 @@ export async function patchIceCandidates(request: Request, consoleAddrs?: Remote
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
export function interceptHttpRequests() {
|
||||
let BLOCKED_URLS: string[] = [];
|
||||
if (getPref(PrefKey.BLOCK_TRACKING)) {
|
||||
@ -283,3 +285,45 @@ export function interceptHttpRequests() {
|
||||
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 { NATIVE_FETCH, BX_FLAGS } from "./bx-flags";
|
||||
import { STATES } from "./global";
|
||||
import { patchIceCandidates } from "./network";
|
||||
import { generateMsDeviceInfo, getOsNameFromResolution, patchIceCandidates } from "./network";
|
||||
import { getPreferredServerRegion } from "./region";
|
||||
import { BypassServerIps } from "@/enums/bypass-servers";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
@ -42,46 +42,6 @@ export class XcloudInterceptor {
|
||||
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) {
|
||||
const bypassServer = getPref<string>(PrefKey.SERVER_BYPASS_RESTRICTION);
|
||||
if (bypassServer !== 'off') {
|
||||
@ -175,24 +135,8 @@ export class XcloudInterceptor {
|
||||
|
||||
// Force stream's resolution
|
||||
if (PREF_STREAM_TARGET_RESOLUTION !== 'auto') {
|
||||
let osName;
|
||||
switch (PREF_STREAM_TARGET_RESOLUTION) {
|
||||
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
|
||||
}
|
||||
|
||||
const osName = getOsNameFromResolution(PREF_STREAM_TARGET_RESOLUTION);
|
||||
headers['x-ms-device-info'] = JSON.stringify(generateMsDeviceInfo(osName));
|
||||
body.settings.osName = osName;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { BxEvent } from "./bx-event";
|
||||
import { SupportedInputType } from "./bx-exposed";
|
||||
import { NATIVE_FETCH } from "./bx-flags";
|
||||
import { STATES } from "./global";
|
||||
import { patchIceCandidates } from "./network";
|
||||
import { generateMsDeviceInfo, getOsNameFromResolution, patchIceCandidates } from "./network";
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "./settings-storages/global-settings-storage";
|
||||
import type { RemotePlayConsoleAddresses } from "@/types/network";
|
||||
@ -13,46 +13,6 @@ import { StreamResolution, TouchControllerMode } from "@/enums/pref-values";
|
||||
export class XhomeInterceptor {
|
||||
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) {
|
||||
try {
|
||||
const clone = request.clone();
|
||||
@ -191,21 +151,8 @@ export class XhomeInterceptor {
|
||||
headers.authorization = `Bearer ${RemotePlayManager.getInstance()!.getXhomeToken()}`;
|
||||
|
||||
// Patch resolution
|
||||
const deviceInfo = XhomeInterceptor.BASE_DEVICE_INFO;
|
||||
const resolution = getPref<StreamResolution>(PrefKey.REMOTE_PLAY_STREAM_RESOLUTION);
|
||||
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 osName = getOsNameFromResolution(getPref<StreamResolution>(PrefKey.REMOTE_PLAY_STREAM_RESOLUTION));
|
||||
headers['x-ms-device-info'] = JSON.stringify(generateMsDeviceInfo(osName));
|
||||
|
||||
const opts: Record<string, any> = {
|
||||
method: clone.method,
|
||||
|
Reference in New Issue
Block a user