mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-30 11:21:43 +02:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
cf1d11185b | |||
21f119e4eb | |||
ebb7920d82 | |||
5ca8eb754c | |||
506f89ea51 | |||
9332f375b8 | |||
dbe0435669 | |||
c1684abf27 | |||
07e4f9dffd | |||
bb980d2cad | |||
102c796c69 | |||
2f7218d165 | |||
b07318e07f | |||
70a8fc9866 |
@ -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.4
|
// @version 3.1.6
|
||||||
// ==/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.4
|
// @version 3.1.6
|
||||||
// @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.4';
|
const SCRIPT_VERSION = '3.1.6';
|
||||||
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": "Spielen im \"STW\"-Modus auf Mobilgeräten erlauben",
|
||||||
|
"en-US": "Allow 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...",
|
||||||
@ -1335,6 +1359,7 @@ const Translations = {
|
|||||||
"tr-TR": "Bu özellik çevrimiçi oyunlarda sizi hile yapıyormuşsunuz gibi gösterebilir",
|
"tr-TR": "Bu özellik çevrimiçi oyunlarda sizi hile yapıyormuşsunuz gibi gösterebilir",
|
||||||
"uk-UA": "Використання цієї функції під час гри онлайн може розглядатися як шахрайство",
|
"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",
|
"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": {
|
"mouse-and-keyboard": {
|
||||||
"de-DE": "Maus & Tastatur",
|
"de-DE": "Maus & Tastatur",
|
||||||
@ -2476,11 +2501,15 @@ 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ı",
|
||||||
"uk-UA": "Розташування сенсорного керування",
|
"uk-UA": "Розташування сенсорного керування",
|
||||||
"vi-VN": "Bố cục điều khiển cảm ứng",
|
"vi-VN": "Bố cục điều khiển cảm ứng",
|
||||||
|
"zh-CN": "触摸控制布局",
|
||||||
},
|
},
|
||||||
"touch-controller": {
|
"touch-controller": {
|
||||||
"de-DE": "Touch-Controller",
|
"de-DE": "Touch-Controller",
|
||||||
@ -3158,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;
|
||||||
method: 'GET',
|
if (!REMOTE_PLAY_SERVER) {
|
||||||
headers: {
|
servers = ['wus2', 'eus', 'uks']; // Possible values: wus2 (WestUS2), eus (EastUS), uks (UkSouth)
|
||||||
'Authorization': `Bearer ${RemotePlay.XHOME_TOKEN}`,
|
} else {
|
||||||
},
|
servers = REMOTE_PLAY_SERVER;
|
||||||
}).then(resp => resp.json())
|
}
|
||||||
.then(json => {
|
|
||||||
|
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;
|
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() {
|
||||||
@ -3442,6 +3496,7 @@ class TouchController {
|
|||||||
static #dataChannel;
|
static #dataChannel;
|
||||||
|
|
||||||
static #customLayouts = {};
|
static #customLayouts = {};
|
||||||
|
static #baseCustomLayouts = {};
|
||||||
static #currentLayoutId;
|
static #currentLayoutId;
|
||||||
|
|
||||||
static enable() {
|
static enable() {
|
||||||
@ -3498,54 +3553,64 @@ class TouchController {
|
|||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getCustomLayouts(xboxTitleId) {
|
static #dispatchLayouts(data) {
|
||||||
const dispatchLayouts = data => {
|
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
||||||
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
data: data,
|
||||||
data: data,
|
});
|
||||||
});
|
};
|
||||||
};
|
|
||||||
|
|
||||||
|
static async getCustomLayouts(xboxTitleId, retries) {
|
||||||
xboxTitleId = '' + xboxTitleId;
|
xboxTitleId = '' + xboxTitleId;
|
||||||
if (xboxTitleId in TouchController.#customLayouts) {
|
if (xboxTitleId in TouchController.#customLayouts) {
|
||||||
dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
TouchController.#dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = 'https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/touch-layouts/';
|
retries = retries || 1;
|
||||||
if (USE_DEV_TOUCH_LAYOUT) {
|
if (retries > 2) {
|
||||||
url += `dev/${xboxTitleId}.json`;
|
TouchController.#customLayouts[xboxTitleId] = null;
|
||||||
} else {
|
// Wait for BX_EXPOSED.touch_layout_manager
|
||||||
url += `${xboxTitleId}.json`;
|
setTimeout(() => TouchController.#dispatchLayouts(null), 1000);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
NATIVE_FETCH(url)
|
|
||||||
.then(resp => resp.json())
|
const baseUrl = `https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/touch-layouts${USE_DEV_TOUCH_LAYOUT ? '/dev' : ''}`;
|
||||||
.then(json => {
|
const url = `${baseUrl}/${xboxTitleId}.json`;
|
||||||
// Normalize data
|
|
||||||
const schema_version = json.schema_version || 1;
|
// Get layout info
|
||||||
let layout;
|
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 {
|
try {
|
||||||
if (schema_version === 1) {
|
const layoutUrl = `${baseUrl}/layouts/${layoutName}.json`;
|
||||||
json.layouts = {
|
const resp = await NATIVE_FETCH(layoutUrl);
|
||||||
default: {
|
const json = await resp.json();
|
||||||
name: 'Default',
|
|
||||||
content: json.layout,
|
baseLayouts = json.layouts;
|
||||||
},
|
TouchController.#baseCustomLayouts[layoutName] = baseLayouts;
|
||||||
};
|
|
||||||
json.default_layout = 'default';
|
|
||||||
delete json.layout;
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
TouchController.#customLayouts[xboxTitleId] = json;
|
Object.assign(layouts, baseLayouts);
|
||||||
|
});
|
||||||
|
|
||||||
// Wait for BX_EXPOSED.touch_layout_manager
|
json.layouts = layouts;
|
||||||
setTimeout(() => dispatchLayouts(json), 1000);
|
TouchController.#customLayouts[xboxTitleId] = json;
|
||||||
})
|
|
||||||
.catch(() => {
|
// Wait for BX_EXPOSED.touch_layout_manager
|
||||||
TouchController.#customLayouts[xboxTitleId] = null;
|
setTimeout(() => TouchController.#dispatchLayouts(json), 1000);
|
||||||
// Wait for BX_EXPOSED.touch_layout_manager
|
} catch (e) {
|
||||||
setTimeout(() => dispatchLayouts(null), 1000);
|
// Retry
|
||||||
});
|
TouchController.getCustomLayouts(xboxTitleId, retries + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadCustomLayout(xboxTitleId, layoutId, delay) {
|
static loadCustomLayout(xboxTitleId, layoutId, delay) {
|
||||||
@ -3588,6 +3653,24 @@ class TouchController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static setup() {
|
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 $fragment = document.createDocumentFragment();
|
||||||
const $style = document.createElement('style');
|
const $style = document.createElement('style');
|
||||||
$fragment.appendChild($style);
|
$fragment.appendChild($style);
|
||||||
@ -6409,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'; }
|
||||||
|
|
||||||
@ -6651,7 +6736,10 @@ 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');
|
const note = __(pref.unsupported ? 'browser-unsupported-feature' : 'mkb-disclaimer');
|
||||||
Preferences.SETTINGS[Preferences.MKB_ENABLED].note = '⚠️ ' + note;
|
Preferences.SETTINGS[Preferences.MKB_ENABLED].note = CE('a', {
|
||||||
|
href: 'https://github.com/redphx/better-xcloud/issues/206#issuecomment-1920475657',
|
||||||
|
target: '_blank',
|
||||||
|
}, '⚠️ ' + note);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -6843,6 +6931,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]: {
|
||||||
@ -7254,6 +7347,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 = [
|
||||||
@ -7286,6 +7391,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
|
||||||
@ -8935,7 +9042,7 @@ 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',
|
||||||
'https://accounts.xboxlive.com/family/memberXuid',
|
// 'https://accounts.xboxlive.com/family/memberXuid',
|
||||||
'https://notificationinbox.xboxlive.com',
|
'https://notificationinbox.xboxlive.com',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -9049,7 +9156,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);
|
||||||
|
|
||||||
@ -9452,6 +9559,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