mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-29 10:51: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==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 6.0.1
|
// @version 6.0.2
|
||||||
// ==/UserScript==
|
// ==/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 {
|
destroy(): void {
|
||||||
this.pointerClient?.stop();
|
this.pointerClient?.stop();
|
||||||
|
this.stop();
|
||||||
|
|
||||||
window.removeEventListener('keyup', this);
|
window.removeEventListener('keyup', this);
|
||||||
|
|
||||||
window.removeEventListener(BxEvent.XCLOUD_DIALOG_SHOWN, 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);
|
window.removeEventListener(BxEvent.XCLOUD_POLLING_MODE_CHANGED, this);
|
||||||
|
|
||||||
this.waitForMouseData(false);
|
this.waitForMouseData(false);
|
||||||
|
document.pointerLockElement && document.exitPointerLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMouseMove(data: MkbMouseMove): void {
|
handleMouseMove(data: MkbMouseMove): void {
|
||||||
|
@ -947,12 +947,23 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
|||||||
streamPageBeforeLoad(str: string) {
|
streamPageBeforeLoad(str: string) {
|
||||||
return PatcherUtils.patchBeforePageLoad(str, 'stream');
|
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([
|
let PATCH_ORDERS = PatcherUtils.filterPatches([
|
||||||
...(getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
...(AppInterface && getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||||
'enableNativeMkb',
|
'enableNativeMkb',
|
||||||
'exposeInputSink',
|
'exposeInputSink',
|
||||||
|
'disableAbsoluteMouse',
|
||||||
] : []),
|
] : []),
|
||||||
|
|
||||||
'modifyPreloadedState',
|
'modifyPreloadedState',
|
||||||
@ -1062,7 +1073,7 @@ let STREAM_PAGE_PATCH_ORDERS = PatcherUtils.filterPatches([
|
|||||||
] : []),
|
] : []),
|
||||||
|
|
||||||
// Native MKB
|
// Native MKB
|
||||||
...(getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
...(AppInterface && getPref<NativeMkbMode>(PrefKey.NATIVE_MKB_MODE) === NativeMkbMode.ON ? [
|
||||||
'patchMouseAndKeyboardEnabled',
|
'patchMouseAndKeyboardEnabled',
|
||||||
'disableNativeRequestPointerLock',
|
'disableNativeRequestPointerLock',
|
||||||
] : []),
|
] : []),
|
||||||
|
@ -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,
|
||||||
|
Reference in New Issue
Block a user