mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-07-03 21:01:43 +02:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
e48b277535 | |||
e2dbf873a6 | |||
6510eac0c3 | |||
3dd83ace6c | |||
45d8aed841 | |||
cf1d11185b | |||
21f119e4eb | |||
ebb7920d82 | |||
5ca8eb754c | |||
506f89ea51 | |||
9332f375b8 | |||
dbe0435669 | |||
c1684abf27 | |||
07e4f9dffd |
@ -1,5 +1,5 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 3.1.5
|
// @version 3.1.8
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 3.1.5
|
// @version 3.1.8
|
||||||
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
||||||
// @author redphx
|
// @author redphx
|
||||||
// @license MIT
|
// @license MIT
|
||||||
@ -14,13 +14,15 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const SCRIPT_VERSION = '3.1.5';
|
const SCRIPT_VERSION = '3.1.8';
|
||||||
const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
|
const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
|
||||||
|
|
||||||
const ENABLE_XCLOUD_LOGGER = false;
|
const ENABLE_XCLOUD_LOGGER = false;
|
||||||
const ENABLE_PRELOAD_BX_UI = false;
|
const ENABLE_PRELOAD_BX_UI = false;
|
||||||
const USE_DEV_TOUCH_LAYOUT = false;
|
const USE_DEV_TOUCH_LAYOUT = false;
|
||||||
|
|
||||||
|
let REMOTE_PLAY_SERVER;
|
||||||
|
|
||||||
const ENABLE_NATIVE_MKB_BETA = false;
|
const ENABLE_NATIVE_MKB_BETA = false;
|
||||||
window.NATIVE_MKB_TITLES = [
|
window.NATIVE_MKB_TITLES = [
|
||||||
// Not working anymore
|
// Not working anymore
|
||||||
@ -1059,6 +1061,28 @@ const Translations = {
|
|||||||
"vi-VN": "Nhanh",
|
"vi-VN": "Nhanh",
|
||||||
"zh-CN": "快速",
|
"zh-CN": "快速",
|
||||||
},
|
},
|
||||||
|
"fortnite-allow-stw-mode": {
|
||||||
|
"de-DE": "Erlaubt das Spielen im \"STW\"-Modus auf Mobilgeräten",
|
||||||
|
"en-US": "Allows playing STW mode on mobile",
|
||||||
|
"es-ES": "Permitir jugar al modo STW en el móvil",
|
||||||
|
"ja-JP": "モバイル版で「世界を救え」をプレイできるようになります",
|
||||||
|
"pl-PL": "Zezwól na granie w tryb STW na urządzeniu mobilnym",
|
||||||
|
"pt-BR": "Permitir a reprodução do modo STW no celular",
|
||||||
|
"tr-TR": "Mobil cihazda Fortnite: Dünyayı Kurtar modunu etkinleştir",
|
||||||
|
"uk-UA": "Дозволити відтворення режиму STW на мобільному пристрої",
|
||||||
|
"vi-VN": "Cho phép chơi chế độ STW trên điện thoại",
|
||||||
|
},
|
||||||
|
"fortnite-force-console-version": {
|
||||||
|
"de-DE": "Fortnite: Erzwinge Konsolenversion",
|
||||||
|
"en-US": "Fortnite: force console version",
|
||||||
|
"es-ES": "Fortnite: forzar versión de consola",
|
||||||
|
"ja-JP": "Fortnite: 強制的にコンソール版を起動する",
|
||||||
|
"pl-PL": "Fortnite: wymuś wersję konsolową",
|
||||||
|
"pt-BR": "Fortnite: forçar versão para console",
|
||||||
|
"tr-TR": "Fortnite'ın konsol sürümünü aç",
|
||||||
|
"uk-UA": "Fortnite: примусова консольна версія",
|
||||||
|
"vi-VN": "Fortnite: bắt buộc phiên bản console",
|
||||||
|
},
|
||||||
"getting-consoles-list": {
|
"getting-consoles-list": {
|
||||||
"de-DE": "Rufe Liste der Konsolen ab...",
|
"de-DE": "Rufe Liste der Konsolen ab...",
|
||||||
"en-US": "Getting the list of consoles...",
|
"en-US": "Getting the list of consoles...",
|
||||||
@ -2477,7 +2501,9 @@ const Translations = {
|
|||||||
"touch-control-layout": {
|
"touch-control-layout": {
|
||||||
"de-DE": "Touch-Steuerungslayout",
|
"de-DE": "Touch-Steuerungslayout",
|
||||||
"en-US": "Touch control layout",
|
"en-US": "Touch control layout",
|
||||||
|
"es-ES": "Diseño de control táctil",
|
||||||
"ja-JP": "タッチコントロールレイアウト",
|
"ja-JP": "タッチコントロールレイアウト",
|
||||||
|
"pl-PL": "Układ sterowania dotykowego",
|
||||||
"pt-BR": "Layout do controle por toque",
|
"pt-BR": "Layout do controle por toque",
|
||||||
"ru-RU": "Расположение сенсорных кнопок",
|
"ru-RU": "Расположение сенсорных кнопок",
|
||||||
"tr-TR": "Dokunmatik kontrol şeması",
|
"tr-TR": "Dokunmatik kontrol şeması",
|
||||||
@ -3161,22 +3187,47 @@ class RemotePlay {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static #getConsolesList(callback) {
|
static async #getConsolesList(callback) {
|
||||||
if (RemotePlay.#CONSOLES) {
|
if (RemotePlay.#CONSOLES) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch('https://wus2.gssv-play-prodxhome.xboxlive.com/v6/servers/home?mr=50', {
|
let servers;
|
||||||
|
if (!REMOTE_PLAY_SERVER) {
|
||||||
|
servers = ['wus2', 'eus', 'uks']; // Possible values: wus2 (WestUS2), eus (EastUS), uks (UkSouth)
|
||||||
|
} else {
|
||||||
|
servers = REMOTE_PLAY_SERVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${RemotePlay.XHOME_TOKEN}`,
|
'Authorization': `Bearer ${RemotePlay.XHOME_TOKEN}`,
|
||||||
},
|
},
|
||||||
}).then(resp => resp.json())
|
};
|
||||||
.then(json => {
|
|
||||||
|
// Test servers one by one
|
||||||
|
for (const server of servers) {
|
||||||
|
try {
|
||||||
|
const url = `https://${server}.gssv-play-prodxhome.xboxlive.com/v6/servers/home?mr=50`;
|
||||||
|
const resp = await fetch(url, options);
|
||||||
|
|
||||||
|
const json = await resp.json();
|
||||||
RemotePlay.#CONSOLES = json.results;
|
RemotePlay.#CONSOLES = json.results;
|
||||||
|
|
||||||
|
// Store working server
|
||||||
|
REMOTE_PLAY_SERVER = server;
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
});
|
break;
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// None of the servers worked
|
||||||
|
if (!REMOTE_PLAY_SERVER) {
|
||||||
|
RemotePlay.#CONSOLES = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static showDialog() {
|
static showDialog() {
|
||||||
@ -3445,6 +3496,7 @@ class TouchController {
|
|||||||
static #dataChannel;
|
static #dataChannel;
|
||||||
|
|
||||||
static #customLayouts = {};
|
static #customLayouts = {};
|
||||||
|
static #baseCustomLayouts = {};
|
||||||
static #currentLayoutId;
|
static #currentLayoutId;
|
||||||
|
|
||||||
static enable() {
|
static enable() {
|
||||||
@ -3507,7 +3559,7 @@ class TouchController {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
static getCustomLayouts(xboxTitleId, retries) {
|
static async getCustomLayouts(xboxTitleId, retries) {
|
||||||
xboxTitleId = '' + xboxTitleId;
|
xboxTitleId = '' + xboxTitleId;
|
||||||
if (xboxTitleId in TouchController.#customLayouts) {
|
if (xboxTitleId in TouchController.#customLayouts) {
|
||||||
TouchController.#dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
TouchController.#dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
||||||
@ -3526,15 +3578,28 @@ class TouchController {
|
|||||||
const url = `${baseUrl}/${xboxTitleId}.json`;
|
const url = `${baseUrl}/${xboxTitleId}.json`;
|
||||||
|
|
||||||
// Get layout info
|
// Get layout info
|
||||||
NATIVE_FETCH(url)
|
try {
|
||||||
.then(resp => resp.json())
|
const resp = await NATIVE_FETCH(url);
|
||||||
.then(json => {
|
const json = await resp.json();
|
||||||
|
|
||||||
const layouts = {};
|
const layouts = {};
|
||||||
|
|
||||||
json.layouts.forEach(async file => {
|
json.layouts.forEach(async layoutName => {
|
||||||
const layoutUrl = `${baseUrl}/layouts/${file}.json`;
|
let baseLayouts = {};
|
||||||
const json = await (await NATIVE_FETCH(layoutUrl)).json();
|
if (layoutName in TouchController.#baseCustomLayouts) {
|
||||||
Object.assign(layouts, json.layouts);
|
baseLayouts = TouchController.#baseCustomLayouts[layoutName];
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const layoutUrl = `${baseUrl}/layouts/${layoutName}.json`;
|
||||||
|
const resp = await NATIVE_FETCH(layoutUrl);
|
||||||
|
const json = await resp.json();
|
||||||
|
|
||||||
|
baseLayouts = json.layouts;
|
||||||
|
TouchController.#baseCustomLayouts[layoutName] = baseLayouts;
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(layouts, baseLayouts);
|
||||||
});
|
});
|
||||||
|
|
||||||
json.layouts = layouts;
|
json.layouts = layouts;
|
||||||
@ -3542,11 +3607,10 @@ class TouchController {
|
|||||||
|
|
||||||
// Wait for BX_EXPOSED.touch_layout_manager
|
// Wait for BX_EXPOSED.touch_layout_manager
|
||||||
setTimeout(() => TouchController.#dispatchLayouts(json), 1000);
|
setTimeout(() => TouchController.#dispatchLayouts(json), 1000);
|
||||||
})
|
} catch (e) {
|
||||||
.catch(() => {
|
|
||||||
// Retry
|
// Retry
|
||||||
TouchController.getCustomLayouts(xboxTitleId, retries + 1);
|
TouchController.getCustomLayouts(xboxTitleId, retries + 1);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadCustomLayout(xboxTitleId, layoutId, delay) {
|
static loadCustomLayout(xboxTitleId, layoutId, delay) {
|
||||||
@ -6428,6 +6492,8 @@ class Preferences {
|
|||||||
static get REMOTE_PLAY_ENABLED() { return 'xhome_enabled'; }
|
static get REMOTE_PLAY_ENABLED() { return 'xhome_enabled'; }
|
||||||
static get REMOTE_PLAY_RESOLUTION() { return 'xhome_resolution'; }
|
static get REMOTE_PLAY_RESOLUTION() { return 'xhome_resolution'; }
|
||||||
|
|
||||||
|
static get GAME_FORTNITE_FORCE_CONSOLE() { return 'game_fortnite_force_console'; }
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
static get DEPRECATED_USE_DESKTOP_CODEC() { return 'use_desktop_codec'; }
|
static get DEPRECATED_USE_DESKTOP_CODEC() { return 'use_desktop_codec'; }
|
||||||
|
|
||||||
@ -6669,8 +6735,21 @@ class Preferences {
|
|||||||
})(),
|
})(),
|
||||||
'ready': () => {
|
'ready': () => {
|
||||||
const pref = Preferences.SETTINGS[Preferences.MKB_ENABLED];
|
const pref = Preferences.SETTINGS[Preferences.MKB_ENABLED];
|
||||||
const note = __(pref.unsupported ? 'browser-unsupported-feature' : 'mkb-disclaimer');
|
|
||||||
Preferences.SETTINGS[Preferences.MKB_ENABLED].note = '⚠️ ' + note;
|
let note;
|
||||||
|
let url;
|
||||||
|
if (pref.unsupported) {
|
||||||
|
note = __('browser-unsupported-feature');
|
||||||
|
url = 'https://github.com/redphx/better-xcloud/issues/206#issuecomment-1920475657';
|
||||||
|
} else {
|
||||||
|
note = __('mkb-disclaimer');
|
||||||
|
url = 'https://better-xcloud.github.io/mouse-and-keyboard/#disclaimer';
|
||||||
|
}
|
||||||
|
|
||||||
|
Preferences.SETTINGS[Preferences.MKB_ENABLED].note = CE('a', {
|
||||||
|
href: url,
|
||||||
|
target: '_blank',
|
||||||
|
}, '⚠️ ' + note);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -6862,6 +6941,11 @@ class Preferences {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
[Preferences.GAME_FORTNITE_FORCE_CONSOLE]: {
|
||||||
|
'default': false,
|
||||||
|
'note': __('fortnite-allow-stw-mode'),
|
||||||
|
},
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
/*
|
/*
|
||||||
[Preferences.DEPRECATED_USE_DESKTOP_CODEC]: {
|
[Preferences.DEPRECATED_USE_DESKTOP_CODEC]: {
|
||||||
@ -7273,6 +7357,18 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
|
|||||||
funcStr = funcStr.replace(text, 'window.BX_EXPOSED["touch_layout_manager"] = this,' + text);
|
funcStr = funcStr.replace(text, 'window.BX_EXPOSED["touch_layout_manager"] = this,' + text);
|
||||||
return funcStr;
|
return funcStr;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
forceFortniteConsole: function(funcStr) {
|
||||||
|
const text = 'sendTouchInputEnabledMessage(e){';
|
||||||
|
if (!funcStr.includes(text)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newCode = `window.location.pathname.includes('/launch/fortnite/') && (e = false);`;
|
||||||
|
|
||||||
|
funcStr = funcStr.replace(text, text + newCode);
|
||||||
|
return funcStr;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static #PATCH_ORDERS = [
|
static #PATCH_ORDERS = [
|
||||||
@ -7305,6 +7401,8 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
|
|||||||
ENABLE_NATIVE_MKB_BETA && 'mkbIsMouseAndKeyboardTitle',
|
ENABLE_NATIVE_MKB_BETA && 'mkbIsMouseAndKeyboardTitle',
|
||||||
HAS_TOUCH_SUPPORT && 'patchUpdateInputConfigurationAsync',
|
HAS_TOUCH_SUPPORT && 'patchUpdateInputConfigurationAsync',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
getPref(Preferences.GAME_FORTNITE_FORCE_CONSOLE) && ['forceFortniteConsole'],
|
||||||
];
|
];
|
||||||
|
|
||||||
// Only when playing
|
// Only when playing
|
||||||
@ -8953,9 +9051,10 @@ function interceptHttpRequests() {
|
|||||||
|
|
||||||
if (getPref(Preferences.BLOCK_SOCIAL_FEATURES)) {
|
if (getPref(Preferences.BLOCK_SOCIAL_FEATURES)) {
|
||||||
BLOCKED_URLS = BLOCKED_URLS.concat([
|
BLOCKED_URLS = BLOCKED_URLS.concat([
|
||||||
'https://peoplehub.xboxlive.com/users/me',
|
'https://peoplehub.xboxlive.com/users/me/people/social',
|
||||||
'https://accounts.xboxlive.com/family/memberXuid',
|
'https://peoplehub.xboxlive.com/users/me/people/recommendations',
|
||||||
'https://notificationinbox.xboxlive.com',
|
'https://notificationinbox.xboxlive.com',
|
||||||
|
// 'https://accounts.xboxlive.com/family/memberXuid',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9032,6 +9131,17 @@ function interceptHttpRequests() {
|
|||||||
let request = arg[0];
|
let request = arg[0];
|
||||||
let url = (typeof request === 'string') ? request : request.url;
|
let url = (typeof request === 'string') ? request : request.url;
|
||||||
|
|
||||||
|
for (let blocked of BLOCKED_URLS) {
|
||||||
|
if (!url.startsWith(blocked)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response('{"acc":1,"webResult":{}}', {
|
||||||
|
status: 200,
|
||||||
|
statusText: '200 OK',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (url.endsWith('/play')) {
|
if (url.endsWith('/play')) {
|
||||||
BxEvent.dispatch(window, BxEvent.STREAM_LOADING);
|
BxEvent.dispatch(window, BxEvent.STREAM_LOADING);
|
||||||
}
|
}
|
||||||
@ -9068,7 +9178,7 @@ function interceptHttpRequests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const index = request.url.indexOf('.xboxlive.com');
|
const index = request.url.indexOf('.xboxlive.com');
|
||||||
let newUrl = 'https://wus2.gssv-play-prodxhome' + request.url.substring(index);
|
let newUrl = `https://${REMOTE_PLAY_SERVER}.gssv-play-prodxhome` + request.url.substring(index);
|
||||||
|
|
||||||
request = new Request(newUrl, opts);
|
request = new Request(newUrl, opts);
|
||||||
|
|
||||||
@ -9359,17 +9469,6 @@ function interceptHttpRequests() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let blocked of BLOCKED_URLS) {
|
|
||||||
if (!url.startsWith(blocked)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Response('{"acc":1,"webResult":{}}', {
|
|
||||||
status: 200,
|
|
||||||
statusText: '200 OK',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return NATIVE_FETCH(...arg);
|
return NATIVE_FETCH(...arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9471,6 +9570,7 @@ function injectSettingsButton($parent) {
|
|||||||
[Preferences.AUDIO_ENABLE_VOLUME_CONTROL]: __('enable-volume-control'),
|
[Preferences.AUDIO_ENABLE_VOLUME_CONTROL]: __('enable-volume-control'),
|
||||||
[Preferences.AUDIO_MIC_ON_PLAYING]: __('enable-mic-on-startup'),
|
[Preferences.AUDIO_MIC_ON_PLAYING]: __('enable-mic-on-startup'),
|
||||||
[Preferences.STREAM_DISABLE_FEEDBACK_DIALOG]: __('disable-post-stream-feedback-dialog'),
|
[Preferences.STREAM_DISABLE_FEEDBACK_DIALOG]: __('disable-post-stream-feedback-dialog'),
|
||||||
|
[Preferences.GAME_FORTNITE_FORCE_CONSOLE]: '🎮 ' + __('fortnite-force-console-version'),
|
||||||
},
|
},
|
||||||
|
|
||||||
[__('mouse-and-keyboard')]: {
|
[__('mouse-and-keyboard')]: {
|
||||||
|
Reference in New Issue
Block a user