mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-29 10:51:44 +02:00
Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
d2ddc2fd23 | |||
a00b0b6879 | |||
83ff859798 | |||
0ef1e8a526 | |||
20caac4821 | |||
dac9823d5b | |||
bcdabbf1b9 | |||
11f3513b0c | |||
9786c7c8ee | |||
e48b277535 | |||
e2dbf873a6 | |||
6510eac0c3 | |||
3dd83ace6c | |||
45d8aed841 | |||
cf1d11185b | |||
21f119e4eb | |||
ebb7920d82 | |||
5ca8eb754c | |||
506f89ea51 | |||
9332f375b8 | |||
dbe0435669 | |||
c1684abf27 | |||
07e4f9dffd | |||
bb980d2cad | |||
102c796c69 | |||
2f7218d165 | |||
b07318e07f | |||
70a8fc9866 | |||
2d9ee16531 | |||
21168803e0 | |||
3068aa8a06 | |||
b6b9ec49f6 | |||
4dc60f965f | |||
2142c4a83c | |||
6b090194c9 | |||
a878150ec3 | |||
5fb1dded42 | |||
ac6879c189 | |||
b8efaf9648 |
@ -1,5 +1,5 @@
|
||||
// ==UserScript==
|
||||
// @name Better xCloud
|
||||
// @namespace https://github.com/redphx
|
||||
// @version 3.1.3
|
||||
// @version 3.2
|
||||
// ==/UserScript==
|
||||
|
@ -1,11 +1,12 @@
|
||||
// ==UserScript==
|
||||
// @name Better xCloud
|
||||
// @namespace https://github.com/redphx
|
||||
// @version 3.1.3
|
||||
// @version 3.2
|
||||
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
||||
// @author redphx
|
||||
// @license MIT
|
||||
// @match https://www.xbox.com/*/play*
|
||||
// @match https://www.xbox.com/*/auth/msa?*loggedIn*
|
||||
// @run-at document-start
|
||||
// @grant none
|
||||
// @updateURL https://raw.githubusercontent.com/redphx/better-xcloud/main/better-xcloud.meta.js
|
||||
@ -13,13 +14,15 @@
|
||||
// ==/UserScript==
|
||||
'use strict';
|
||||
|
||||
const SCRIPT_VERSION = '3.1.3';
|
||||
const SCRIPT_VERSION = '3.2';
|
||||
const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
|
||||
|
||||
const ENABLE_XCLOUD_LOGGER = false;
|
||||
const ENABLE_PRELOAD_BX_UI = false;
|
||||
const USE_DEV_TOUCH_LAYOUT = false;
|
||||
|
||||
let REMOTE_PLAY_SERVER;
|
||||
|
||||
const ENABLE_NATIVE_MKB_BETA = false;
|
||||
window.NATIVE_MKB_TITLES = [
|
||||
// Not working anymore
|
||||
@ -38,6 +41,17 @@ window.NATIVE_MKB_TITLES = [
|
||||
// '9P731Z4BBCT3', // Atomic Heart
|
||||
];
|
||||
|
||||
if (window.location.pathname.includes('/auth/msa')) {
|
||||
window.addEventListener('load', e => {
|
||||
window.location.search.includes('loggedIn') && setTimeout(() => {
|
||||
const location = window.location;
|
||||
location.pathname.includes('/play') && location.reload(true);
|
||||
}, 2000);
|
||||
});
|
||||
// Stop processing the script
|
||||
throw new Error('[Better xCloud] Refreshing the page after logging in');
|
||||
}
|
||||
|
||||
console.log(`[Better xCloud] readyState: ${document.readyState}`);
|
||||
|
||||
const BxEvent = {
|
||||
@ -926,6 +940,26 @@ const Translations = {
|
||||
"vi-VN": "Bật tính năng phím tắt cho bộ điều khiển",
|
||||
"zh-CN": "启用手柄快捷方式",
|
||||
},
|
||||
"enable-local-co-op-support": {
|
||||
"en-US": "Enable local co-op support",
|
||||
"ja-JP": "ローカルマルチプレイのサポートを有効化",
|
||||
"pl-PL": "Włącz lokalny co-op",
|
||||
"pt-BR": "Habilitar o suporte a co-op local",
|
||||
"ru-RU": "Включить поддержку локальной кооперативной игры",
|
||||
"tr-TR": "Yerel çok oyuncu desteğini aktive et",
|
||||
"uk-UA": "Увімкнути локальну co-op підтримку",
|
||||
"vi-VN": "Kích hoạt tính năng chơi chung cục bộ",
|
||||
},
|
||||
"enable-local-co-op-support-note": {
|
||||
"en-US": "Only works if the game doesn't require a different profile",
|
||||
"ja-JP": "別アカウントでのサインインを必要としないゲームのみ動作します",
|
||||
"pl-PL": "Działa tylko wtedy, gdy gra nie wymaga innego profilu",
|
||||
"pt-BR": "Só funciona se o jogo não exigir um perfil diferente",
|
||||
"ru-RU": "Работает только в том случае, если игра не требует другого профиля",
|
||||
"tr-TR": "Bu seçenek ancak oyun ayrı profillere giriş yapılmasını istemiyorsa etki eder",
|
||||
"uk-UA": "Працює, лише якщо для гри не потрібен інший профіль",
|
||||
"vi-VN": "Chỉ hoạt động nếu game không yêu cầu thêm tài khoản khác",
|
||||
},
|
||||
"enable-mic-on-startup": {
|
||||
"de-DE": "Mikrofon bei Spielstart aktivieren",
|
||||
"en-US": "Enable microphone on game launch",
|
||||
@ -1047,6 +1081,30 @@ const Translations = {
|
||||
"vi-VN": "Nhanh",
|
||||
"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",
|
||||
"ru-RU": "Позволяет играть в режиме STW на мобильных устройствах",
|
||||
"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",
|
||||
"ru-RU": "Fortnite: форсированная консольная версия",
|
||||
"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": {
|
||||
"de-DE": "Rufe Liste der Konsolen ab...",
|
||||
"en-US": "Getting the list of consoles...",
|
||||
@ -1320,8 +1378,10 @@ const Translations = {
|
||||
"pl-PL": "Używanie tej funkcji podczas grania online może być postrzegane jako oszukiwanie",
|
||||
"pt-BR": "Usar esta função em jogos online pode ser considerado como uma forma de trapaça",
|
||||
"ru-RU": "Использование этой функции при игре онлайн может рассматриваться как читерство",
|
||||
"tr-TR": "Bu özellik çevrimiçi oyunlarda sizi hile yapıyormuşsunuz gibi gösterebilir",
|
||||
"uk-UA": "Використання цієї функції під час гри онлайн може розглядатися як шахрайство",
|
||||
"vi-VN": "Sử dụng chức năng này khi chơi trực tuyến có thể bị xem là gian lận",
|
||||
"zh-CN": "游玩在线游戏时,使用此功能可能被视为作弊。",
|
||||
},
|
||||
"mouse-and-keyboard": {
|
||||
"de-DE": "Maus & Tastatur",
|
||||
@ -2460,6 +2520,19 @@ const Translations = {
|
||||
"vi-VN": "Phía trên bên phải",
|
||||
"zh-CN": "右上角",
|
||||
},
|
||||
"touch-control-layout": {
|
||||
"de-DE": "Touch-Steuerungslayout",
|
||||
"en-US": "Touch control layout",
|
||||
"es-ES": "Diseño de control táctil",
|
||||
"ja-JP": "タッチコントロールレイアウト",
|
||||
"pl-PL": "Układ sterowania dotykowego",
|
||||
"pt-BR": "Layout do controle por toque",
|
||||
"ru-RU": "Расположение сенсорных кнопок",
|
||||
"tr-TR": "Dokunmatik kontrol şeması",
|
||||
"uk-UA": "Розташування сенсорного керування",
|
||||
"vi-VN": "Bố cục điều khiển cảm ứng",
|
||||
"zh-CN": "触摸控制布局",
|
||||
},
|
||||
"touch-controller": {
|
||||
"de-DE": "Touch-Controller",
|
||||
"en-US": "Touch controller",
|
||||
@ -3136,22 +3209,47 @@ class RemotePlay {
|
||||
});
|
||||
}
|
||||
|
||||
static #getConsolesList(callback) {
|
||||
static async #getConsolesList(callback) {
|
||||
if (RemotePlay.#CONSOLES) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
fetch('https://wus2.gssv-play-prodxhome.xboxlive.com/v6/servers/home?mr=50', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${RemotePlay.XHOME_TOKEN}`,
|
||||
},
|
||||
}).then(resp => resp.json())
|
||||
.then(json => {
|
||||
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',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${RemotePlay.XHOME_TOKEN}`,
|
||||
},
|
||||
};
|
||||
|
||||
// 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;
|
||||
|
||||
// Store working server
|
||||
REMOTE_PLAY_SERVER = server;
|
||||
|
||||
callback();
|
||||
});
|
||||
break;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// None of the servers worked
|
||||
if (!REMOTE_PLAY_SERVER) {
|
||||
RemotePlay.#CONSOLES = [];
|
||||
}
|
||||
}
|
||||
|
||||
static showDialog() {
|
||||
@ -3420,6 +3518,7 @@ class TouchController {
|
||||
static #dataChannel;
|
||||
|
||||
static #customLayouts = {};
|
||||
static #baseCustomLayouts = {};
|
||||
static #currentLayoutId;
|
||||
|
||||
static enable() {
|
||||
@ -3476,54 +3575,64 @@ class TouchController {
|
||||
}, 10);
|
||||
}
|
||||
|
||||
static getCustomLayouts(xboxTitleId) {
|
||||
const dispatchLayouts = data => {
|
||||
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
||||
data: data,
|
||||
});
|
||||
};
|
||||
static #dispatchLayouts(data) {
|
||||
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
||||
data: data,
|
||||
});
|
||||
};
|
||||
|
||||
static async getCustomLayouts(xboxTitleId, retries) {
|
||||
xboxTitleId = '' + xboxTitleId;
|
||||
if (xboxTitleId in TouchController.#customLayouts) {
|
||||
dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
||||
TouchController.#dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
||||
return;
|
||||
}
|
||||
|
||||
let url = 'https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/touch-layouts/';
|
||||
if (USE_DEV_TOUCH_LAYOUT) {
|
||||
url += `dev/${xboxTitleId}.json`;
|
||||
} else {
|
||||
url += `${xboxTitleId}.json`;
|
||||
retries = retries || 1;
|
||||
if (retries > 2) {
|
||||
TouchController.#customLayouts[xboxTitleId] = null;
|
||||
// Wait for BX_EXPOSED.touch_layout_manager
|
||||
setTimeout(() => TouchController.#dispatchLayouts(null), 1000);
|
||||
return;
|
||||
}
|
||||
NATIVE_FETCH(url)
|
||||
.then(resp => resp.json())
|
||||
.then(json => {
|
||||
// Normalize data
|
||||
const schema_version = json.schema_version || 1;
|
||||
let layout;
|
||||
|
||||
const baseUrl = `https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/touch-layouts${USE_DEV_TOUCH_LAYOUT ? '/dev' : ''}`;
|
||||
const url = `${baseUrl}/${xboxTitleId}.json`;
|
||||
|
||||
// Get layout info
|
||||
try {
|
||||
const resp = await NATIVE_FETCH(url);
|
||||
const json = await resp.json();
|
||||
|
||||
const layouts = {};
|
||||
|
||||
json.layouts.forEach(async layoutName => {
|
||||
let baseLayouts = {};
|
||||
if (layoutName in TouchController.#baseCustomLayouts) {
|
||||
baseLayouts = TouchController.#baseCustomLayouts[layoutName];
|
||||
} else {
|
||||
try {
|
||||
if (schema_version === 1) {
|
||||
json.layouts = {
|
||||
default: {
|
||||
name: 'Default',
|
||||
content: json.layout,
|
||||
},
|
||||
};
|
||||
json.default_layout = 'default';
|
||||
delete json.layout;
|
||||
}
|
||||
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) {}
|
||||
}
|
||||
|
||||
TouchController.#customLayouts[xboxTitleId] = json;
|
||||
Object.assign(layouts, baseLayouts);
|
||||
});
|
||||
|
||||
// Wait for BX_EXPOSED.touch_layout_manager
|
||||
setTimeout(() => dispatchLayouts(json), 1000);
|
||||
})
|
||||
.catch(() => {
|
||||
TouchController.#customLayouts[xboxTitleId] = null;
|
||||
// Wait for BX_EXPOSED.touch_layout_manager
|
||||
setTimeout(() => dispatchLayouts(null), 1000);
|
||||
});
|
||||
json.layouts = layouts;
|
||||
TouchController.#customLayouts[xboxTitleId] = json;
|
||||
|
||||
// Wait for BX_EXPOSED.touch_layout_manager
|
||||
setTimeout(() => TouchController.#dispatchLayouts(json), 1000);
|
||||
} catch (e) {
|
||||
// Retry
|
||||
TouchController.getCustomLayouts(xboxTitleId, retries + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static loadCustomLayout(xboxTitleId, layoutId, delay) {
|
||||
@ -3531,9 +3640,12 @@ class TouchController {
|
||||
return;
|
||||
}
|
||||
|
||||
const layoutChanged = TouchController.#currentLayoutId !== layoutId;
|
||||
|
||||
TouchController.#currentLayoutId = layoutId;
|
||||
xboxTitleId = '' + xboxTitleId;
|
||||
|
||||
// Get layout data
|
||||
const layoutData = TouchController.#customLayouts[xboxTitleId];
|
||||
if (!xboxTitleId || !layoutId || !layoutData) {
|
||||
TouchController.#enable && TouchController.#showDefault();
|
||||
@ -3541,23 +3653,46 @@ class TouchController {
|
||||
}
|
||||
|
||||
const layout = (layoutData.layouts[layoutId] || layoutData.layouts[layoutData.default_layout]);
|
||||
layout && setTimeout(() => {
|
||||
window.BX_EXPOSED.touch_layout_manager.changeLayoutForScope({
|
||||
type: 'showLayout',
|
||||
scope: xboxTitleId,
|
||||
subscope: 'base',
|
||||
layout: {
|
||||
id: 'System.Standard',
|
||||
displayName: 'System',
|
||||
layoutFile: {
|
||||
content: layout.content,
|
||||
},
|
||||
}
|
||||
});
|
||||
}, delay);
|
||||
if (layout) {
|
||||
// Show a toast with layout's name
|
||||
layoutChanged && Toast.show(__('touch-control-layout'), layout.name);
|
||||
|
||||
setTimeout(() => {
|
||||
window.BX_EXPOSED.touch_layout_manager.changeLayoutForScope({
|
||||
type: 'showLayout',
|
||||
scope: xboxTitleId,
|
||||
subscope: 'base',
|
||||
layout: {
|
||||
id: 'System.Standard',
|
||||
displayName: 'System',
|
||||
layoutFile: {
|
||||
content: layout.content,
|
||||
},
|
||||
}
|
||||
});
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
|
||||
static setup() {
|
||||
// Function for testing touch control
|
||||
window.BX_EXPOSED.test_touch_control = content => {
|
||||
const { touch_layout_manager } = window.BX_EXPOSED;
|
||||
|
||||
touch_layout_manager && touch_layout_manager.changeLayoutForScope({
|
||||
type: 'showLayout',
|
||||
scope: '' + GAME_XBOX_TITLE_ID,
|
||||
subscope: 'base',
|
||||
layout: {
|
||||
id: 'System.Standard',
|
||||
displayName: 'Custom',
|
||||
layoutFile: {
|
||||
content: content,
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const $fragment = document.createDocumentFragment();
|
||||
const $style = document.createElement('style');
|
||||
$fragment.appendChild($style);
|
||||
@ -3620,6 +3755,7 @@ class TouchController {
|
||||
setTimeout(TouchController.#show, 1000);
|
||||
});
|
||||
|
||||
let focused = false;
|
||||
dataChannel.addEventListener('message', msg => {
|
||||
if (msg.origin === 'better-xcloud' || typeof msg.data !== 'string') {
|
||||
return;
|
||||
@ -3627,7 +3763,13 @@ class TouchController {
|
||||
|
||||
// Dispatch a message to display generic touch controller
|
||||
if (msg.data.includes('touchcontrols/showtitledefault')) {
|
||||
TouchController.#enable && TouchController.getCustomLayouts(GAME_XBOX_TITLE_ID);
|
||||
if (TouchController.#enable) {
|
||||
if (focused) {
|
||||
TouchController.getCustomLayouts(GAME_XBOX_TITLE_ID);
|
||||
} else {
|
||||
TouchController.#showDefault();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3637,6 +3779,7 @@ class TouchController {
|
||||
const json = JSON.parse(JSON.parse(msg.data).content);
|
||||
TouchController.#toggleBar(json.focused);
|
||||
|
||||
focused = json.focused;
|
||||
if (!json.focused) {
|
||||
TouchController.#show();
|
||||
}
|
||||
@ -6326,6 +6469,7 @@ class Preferences {
|
||||
|
||||
static get STREAM_DISABLE_FEEDBACK_DIALOG() { return 'stream_disable_feedback_dialog'; }
|
||||
|
||||
static get CONTROLLER_SUPPORT_LOCAL_CO_OP() { return 'controller_local_co_op'; }
|
||||
static get CONTROLLER_ENABLE_SHORTCUTS() { return 'controller_enable_shortcuts'; }
|
||||
static get CONTROLLER_ENABLE_VIBRATION() { return 'controller_enable_vibration'; }
|
||||
static get CONTROLLER_DEVICE_VIBRATION() { return 'controller_device_vibration'; }
|
||||
@ -6371,6 +6515,8 @@ class Preferences {
|
||||
static get REMOTE_PLAY_ENABLED() { return 'xhome_enabled'; }
|
||||
static get REMOTE_PLAY_RESOLUTION() { return 'xhome_resolution'; }
|
||||
|
||||
static get GAME_FORTNITE_FORCE_CONSOLE() { return 'game_fortnite_force_console'; }
|
||||
|
||||
// Deprecated
|
||||
static get DEPRECATED_USE_DESKTOP_CODEC() { return 'use_desktop_codec'; }
|
||||
|
||||
@ -6440,7 +6586,7 @@ class Preferences {
|
||||
},
|
||||
},
|
||||
[Preferences.STREAM_TARGET_RESOLUTION]: {
|
||||
'default': 'auto',
|
||||
'default': '1080p',
|
||||
'options': {
|
||||
'auto': __('default'),
|
||||
'1080p': '1080p',
|
||||
@ -6503,10 +6649,16 @@ class Preferences {
|
||||
return options;
|
||||
})(),
|
||||
'ready': () => {
|
||||
const options = Preferences.SETTINGS[Preferences.STREAM_CODEC_PROFILE].options;
|
||||
if (Object.keys(options).length <= 1) {
|
||||
Preferences.SETTINGS[Preferences.STREAM_CODEC_PROFILE].unsupported = true;
|
||||
Preferences.SETTINGS[Preferences.STREAM_CODEC_PROFILE].note = '⚠️ ' + __('browser-unsupported-feature');
|
||||
const setting = Preferences.SETTINGS[Preferences.STREAM_CODEC_PROFILE]
|
||||
const options = setting.options;
|
||||
const keys = Object.keys(options);
|
||||
|
||||
if (keys.length <= 1) { // Unsupported
|
||||
setting.unsupported = true;
|
||||
setting.note = '⚠️ ' + __('browser-unsupported-feature');
|
||||
} else {
|
||||
// Set default value to the best codec profile
|
||||
// setting.default = keys[keys.length - 1];
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -6528,13 +6680,19 @@ class Preferences {
|
||||
'default': false,
|
||||
},
|
||||
[Preferences.STREAM_TOUCH_CONTROLLER]: {
|
||||
'default': 'default',
|
||||
'default': 'all',
|
||||
'options': {
|
||||
'default': __('default'),
|
||||
'all': __('tc-all-games'),
|
||||
'off': __('off'),
|
||||
},
|
||||
'unsupported': !HAS_TOUCH_SUPPORT,
|
||||
'ready': () => {
|
||||
const setting = Preferences.SETTINGS[Preferences.STREAM_TOUCH_CONTROLLER];
|
||||
if (setting.unsupported) {
|
||||
setting.default = 'off';
|
||||
}
|
||||
},
|
||||
},
|
||||
[Preferences.STREAM_TOUCH_CONTROLLER_STYLE_STANDARD]: {
|
||||
'default': 'default',
|
||||
@ -6563,6 +6721,14 @@ class Preferences {
|
||||
'default': false,
|
||||
},
|
||||
|
||||
[Preferences.CONTROLLER_SUPPORT_LOCAL_CO_OP]: {
|
||||
'default': false,
|
||||
'note':CE('a', {
|
||||
href: 'https://github.com/redphx/better-xcloud/discussions/275',
|
||||
target: '_blank',
|
||||
}, __('enable-local-co-op-support-note')),
|
||||
},
|
||||
|
||||
[Preferences.CONTROLLER_ENABLE_SHORTCUTS]: {
|
||||
'default': false,
|
||||
},
|
||||
@ -6600,8 +6766,21 @@ class Preferences {
|
||||
})(),
|
||||
'ready': () => {
|
||||
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);
|
||||
},
|
||||
},
|
||||
|
||||
@ -6729,7 +6908,7 @@ class Preferences {
|
||||
|
||||
|
||||
[Preferences.STATS_ITEMS]: {
|
||||
'default': [StreamStats.PING, StreamStats.FPS, StreamStats.PACKETS_LOST, StreamStats.FRAMES_LOST],
|
||||
'default': [StreamStats.PING, StreamStats.FPS, StreamStats.BITRATE, StreamStats.DECODE_TIME, StreamStats.PACKETS_LOST, StreamStats.FRAMES_LOST],
|
||||
'multiple_options': {
|
||||
[StreamStats.PING]: `${StreamStats.PING.toUpperCase()}: ${__('stat-ping')}`,
|
||||
[StreamStats.FPS]: `${StreamStats.FPS.toUpperCase()}: ${__('stat-fps')}`,
|
||||
@ -6746,10 +6925,10 @@ class Preferences {
|
||||
'default': false,
|
||||
},
|
||||
[Preferences.STATS_QUICK_GLANCE]: {
|
||||
'default': false,
|
||||
'default': true,
|
||||
},
|
||||
[Preferences.STATS_POSITION]: {
|
||||
'default': 'top-left',
|
||||
'default': 'top-right',
|
||||
'options': {
|
||||
'top-left': __('top-left'),
|
||||
'top-center': __('top-center'),
|
||||
@ -6793,7 +6972,13 @@ class Preferences {
|
||||
},
|
||||
},
|
||||
|
||||
[Preferences.GAME_FORTNITE_FORCE_CONSOLE]: {
|
||||
'default': false,
|
||||
'note': __('fortnite-allow-stw-mode'),
|
||||
},
|
||||
|
||||
// Deprecated
|
||||
/*
|
||||
[Preferences.DEPRECATED_USE_DESKTOP_CODEC]: {
|
||||
'default': false,
|
||||
'migrate': function(savedPrefs, value) {
|
||||
@ -6802,6 +6987,7 @@ class Preferences {
|
||||
savedPrefs[Preferences.STREAM_CODEC_PROFILE] = quality;
|
||||
},
|
||||
},
|
||||
*/
|
||||
}
|
||||
|
||||
#storage = localStorage;
|
||||
@ -6816,12 +7002,14 @@ class Preferences {
|
||||
savedPrefs = JSON.parse(savedPrefs);
|
||||
|
||||
for (let settingId in Preferences.SETTINGS) {
|
||||
if (!(settingId in savedPrefs)) {
|
||||
continue;
|
||||
}
|
||||
const setting = Preferences.SETTINGS[settingId];
|
||||
setting && setting.migrate && setting.migrate.call(this, savedPrefs, savedPrefs[settingId]);
|
||||
setting && setting.ready && setting.ready.call(this);
|
||||
setting.ready && setting.ready.call(this);
|
||||
|
||||
/*
|
||||
if (setting.migrate && !(settingId in savedPrefs)) {
|
||||
setting.migrate.call(this, savedPrefs, savedPrefs[settingId]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
for (let settingId in Preferences.SETTINGS) {
|
||||
@ -7126,12 +7314,12 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
|
||||
},
|
||||
|
||||
mkbIsMouseAndKeyboardTitle: function(funcStr) {
|
||||
const text = 'isMouseAndKeyboardTitle:()=>yn';
|
||||
const text = 'isMouseAndKeyboardTitle:()=>';
|
||||
if (!funcStr.includes(text)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return funcStr.replace(text, `isMouseAndKeyboardTitle:()=>(function(e) { return e && e.details ? window.NATIVE_MKB_TITLES.includes(e.details.productId) : true; })`);
|
||||
return funcStr.replace(text, `isMouseAndKeyboardTitle:()=>(function(e) { return e && e.details ? window.NATIVE_MKB_TITLES.includes(e.details.productId) : true; }),uwuwu:()=>`);
|
||||
},
|
||||
|
||||
mkbMouseAndKeyboardEnabled: function(funcStr) {
|
||||
@ -7172,6 +7360,7 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log('[Better xCloud] Remaining patches:', Patcher.#PATCH_ORDERS);
|
||||
Patcher.#PATCH_ORDERS = Patcher.#PATCH_ORDERS.concat(Patcher.#PLAYING_PATCH_ORDERS);
|
||||
Patcher.#cleanupPatches();
|
||||
|
||||
@ -7200,6 +7389,47 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
|
||||
funcStr = funcStr.replace(text, 'window.BX_EXPOSED["touch_layout_manager"] = this,' + text);
|
||||
return funcStr;
|
||||
},
|
||||
|
||||
supportLocalCoOp: function(funcStr) {
|
||||
const text = 'this.gamepadMappingsToSend=[],';
|
||||
if (!funcStr.includes(text)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const newCode = `
|
||||
true;
|
||||
|
||||
let onGamepadChangedStr = this.onGamepadChanged.toString();
|
||||
onGamepadChangedStr = onGamepadChangedStr.replaceAll('0', 'arguments[1]');
|
||||
eval(\`this.onGamepadChanged = function \${onGamepadChangedStr}\`);
|
||||
|
||||
let onGamepadInputStr = this.onGamepadInput.toString();
|
||||
const match = onGamepadInputStr.match(/(\\w+\\.GamepadIndex)/);
|
||||
|
||||
if (match) {
|
||||
const gamepadIndexVar = match[0];
|
||||
onGamepadInputStr = onGamepadInputStr.replace('this.gamepadStates.get(', \`this.gamepadStates.get(\${gamepadIndexVar},\`);
|
||||
eval(\`this.onGamepadInput = function \${onGamepadInputStr}\`);
|
||||
console.log('[Better xCloud] Successfully patched local co-op support');
|
||||
}
|
||||
|
||||
true,
|
||||
`;
|
||||
funcStr = funcStr.replace(text, text + newCode );
|
||||
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 = [
|
||||
@ -7213,13 +7443,15 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
|
||||
getPref(Preferences.UI_LAYOUT) === 'tv' && ['tvLayout'],
|
||||
|
||||
ENABLE_XCLOUD_LOGGER && [
|
||||
'enableXcloudLogger',
|
||||
'enableConsoleLogging',
|
||||
'enableXcloudLogger',
|
||||
],
|
||||
|
||||
getPref(Preferences.CONTROLLER_SUPPORT_LOCAL_CO_OP) && ['supportLocalCoOp'],
|
||||
|
||||
getPref(Preferences.BLOCK_TRACKING) && [
|
||||
'disableTrackEvent',
|
||||
'blockWebRtcStatsCollector',
|
||||
'disableTrackEvent',
|
||||
],
|
||||
|
||||
getPref(Preferences.REMOTE_PLAY_ENABLED) && [
|
||||
@ -7232,6 +7464,8 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
|
||||
ENABLE_NATIVE_MKB_BETA && 'mkbIsMouseAndKeyboardTitle',
|
||||
HAS_TOUCH_SUPPORT && 'patchUpdateInputConfigurationAsync',
|
||||
],
|
||||
|
||||
getPref(Preferences.GAME_FORTNITE_FORCE_CONSOLE) && ['forceFortniteConsole'],
|
||||
];
|
||||
|
||||
// Only when playing
|
||||
@ -8261,16 +8495,18 @@ div[class*=StreamMenu-module__menuContainer] > div[class*=Menu-module] {
|
||||
font-size: 14px;
|
||||
display: inline-block;
|
||||
padding: 12px 16px;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.bx-toast-status {
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
text-transform: uppercase;
|
||||
display: inline-block;
|
||||
background: #515863;
|
||||
padding: 12px 16px;
|
||||
color: #fff;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.bx-number-stepper span {
|
||||
@ -8878,9 +9114,10 @@ function interceptHttpRequests() {
|
||||
|
||||
if (getPref(Preferences.BLOCK_SOCIAL_FEATURES)) {
|
||||
BLOCKED_URLS = BLOCKED_URLS.concat([
|
||||
'https://peoplehub.xboxlive.com/users/me',
|
||||
'https://accounts.xboxlive.com/family/memberXuid',
|
||||
'https://peoplehub.xboxlive.com/users/me/people/social',
|
||||
'https://peoplehub.xboxlive.com/users/me/people/recommendations',
|
||||
'https://notificationinbox.xboxlive.com',
|
||||
// 'https://accounts.xboxlive.com/family/memberXuid',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -8957,6 +9194,17 @@ function interceptHttpRequests() {
|
||||
let request = arg[0];
|
||||
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')) {
|
||||
BxEvent.dispatch(window, BxEvent.STREAM_LOADING);
|
||||
}
|
||||
@ -8993,7 +9241,7 @@ function interceptHttpRequests() {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -9028,7 +9276,18 @@ function interceptHttpRequests() {
|
||||
|
||||
return promise.then(response => {
|
||||
return response.clone().json().then(obj => {
|
||||
if (obj[0].supportedTabs.length > 0) {
|
||||
const xboxTitleId = JSON.parse(opts.body).titleIds[0];
|
||||
GAME_XBOX_TITLE_ID = xboxTitleId;
|
||||
|
||||
const inputConfigs = obj[0];
|
||||
|
||||
let hasTouchSupport = inputConfigs.supportedTabs.length > 0;
|
||||
if (!hasTouchSupport) {
|
||||
const supportedInputTypes = inputConfigs.supportedInputTypes;
|
||||
hasTouchSupport = supportedInputTypes.includes('NativeTouch');
|
||||
}
|
||||
|
||||
if (hasTouchSupport) {
|
||||
TouchController.disable();
|
||||
|
||||
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
||||
@ -9036,9 +9295,6 @@ function interceptHttpRequests() {
|
||||
});
|
||||
} else {
|
||||
TouchController.enable();
|
||||
|
||||
const xboxTitleId = JSON.parse(opts.body).titleIds[0];
|
||||
GAME_XBOX_TITLE_ID = xboxTitleId;
|
||||
TouchController.getCustomLayouts(xboxTitleId);
|
||||
}
|
||||
|
||||
@ -9276,17 +9532,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);
|
||||
}
|
||||
}
|
||||
@ -9385,6 +9630,8 @@ function injectSettingsButton($parent) {
|
||||
[__('stream')]: {
|
||||
[Preferences.STREAM_TARGET_RESOLUTION]: __('target-resolution'),
|
||||
[Preferences.STREAM_CODEC_PROFILE]: __('visual-quality'),
|
||||
[Preferences.CONTROLLER_SUPPORT_LOCAL_CO_OP]: '🛋️ ' + __('enable-local-co-op-support'),
|
||||
[Preferences.GAME_FORTNITE_FORCE_CONSOLE]: '🎮 ' + __('fortnite-force-console-version'),
|
||||
[Preferences.AUDIO_ENABLE_VOLUME_CONTROL]: __('enable-volume-control'),
|
||||
[Preferences.AUDIO_MIC_ON_PLAYING]: __('enable-mic-on-startup'),
|
||||
[Preferences.STREAM_DISABLE_FEEDBACK_DIALOG]: __('disable-post-stream-feedback-dialog'),
|
||||
@ -10230,7 +10477,7 @@ function setupQuickSettingsBar() {
|
||||
},
|
||||
{
|
||||
pref: Preferences.STATS_QUICK_GLANCE,
|
||||
label: __('enable-quick-glance-mode'),
|
||||
label: '👀 ' + __('enable-quick-glance-mode'),
|
||||
onChange: e => {
|
||||
e.target.checked ? StreamStats.quickGlanceSetup() : StreamStats.quickGlanceStop();
|
||||
},
|
||||
@ -10635,6 +10882,7 @@ if (getPref(Preferences.AUDIO_ENABLE_VOLUME_CONTROL)) {
|
||||
window.AudioContext = function() {
|
||||
const ctx = new OrgAudioContext();
|
||||
STREAM_AUDIO_CONTEXT = ctx;
|
||||
STREAM_AUDIO_GAIN_NODE = null;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@ -10682,6 +10930,13 @@ RTCPeerConnection.prototype.createDataChannel = function() {
|
||||
const OrgRTCPeerConnection = window.RTCPeerConnection;
|
||||
window.RTCPeerConnection = function() {
|
||||
STREAM_WEBRTC = new OrgRTCPeerConnection();
|
||||
|
||||
STREAM_WEBRTC.addEventListener('connectionstatechange', e => {
|
||||
if (STREAM_WEBRTC.connectionState === 'connecting') {
|
||||
STREAM_AUDIO_GAIN_NODE = null;
|
||||
}
|
||||
console.log('connectionState', STREAM_WEBRTC.connectionState);
|
||||
});
|
||||
return STREAM_WEBRTC;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user