Compare commits

..

13 Commits

Author SHA1 Message Date
20caac4821 Bump version to 3.1.9 2024-03-01 17:19:09 +07:00
dac9823d5b Change default values of stream stats 2024-03-01 17:04:14 +07:00
bcdabbf1b9 Stop setting codec's default value to the best codec profile 2024-02-29 18:02:53 +07:00
11f3513b0c Fix no audio when the stream drops (#259) 2024-02-29 17:31:30 +07:00
9786c7c8ee Fix native MKB not working 2024-02-29 16:54:23 +07:00
e48b277535 Bump version to 3.1.8 2024-02-15 16:46:56 +07:00
e2dbf873a6 Update translations 2024-02-15 16:46:28 +07:00
6510eac0c3 Fix error while loading profile page 2024-02-15 16:23:06 +07:00
3dd83ace6c Fix mkb's note 2024-02-15 15:49:28 +07:00
45d8aed841 Bump version to 3.1.7 2024-02-15 11:08:02 +07:00
cf1d11185b Add a link for MKB's note 2024-02-14 17:54:03 +07:00
21f119e4eb Update translations 2024-02-14 17:45:05 +07:00
ebb7920d82 Fortnite: allow playing console version on mobile 2024-02-12 19:40:28 +07:00
2 changed files with 96 additions and 27 deletions

View File

@ -1,5 +1,5 @@
// ==UserScript==
// @name Better xCloud
// @namespace https://github.com/redphx
// @version 3.1.6
// @version 3.1.9
// ==/UserScript==

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @name Better xCloud
// @namespace https://github.com/redphx
// @version 3.1.6
// @version 3.1.9
// @description Improve Xbox Cloud Gaming (xCloud) experience
// @author redphx
// @license MIT
@ -14,7 +14,7 @@
// ==/UserScript==
'use strict';
const SCRIPT_VERSION = '3.1.6';
const SCRIPT_VERSION = '3.1.9';
const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
const ENABLE_XCLOUD_LOGGER = false;
@ -1061,6 +1061,28 @@ 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",
"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": {
"de-DE": "Rufe Liste der Konsolen ab...",
"en-US": "Getting the list of consoles...",
@ -2479,7 +2501,9 @@ const Translations = {
"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ı",
@ -6468,6 +6492,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'; }
@ -6609,7 +6635,7 @@ class Preferences {
setting.note = '⚠️ ' + __('browser-unsupported-feature');
} else {
// Set default value to the best codec profile
setting.default = keys[keys.length - 1];
// setting.default = keys[keys.length - 1];
}
},
},
@ -6709,8 +6735,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);
},
},
@ -6838,7 +6877,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')}`,
@ -6855,10 +6894,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'),
@ -6902,6 +6941,11 @@ class Preferences {
},
},
[Preferences.GAME_FORTNITE_FORCE_CONSOLE]: {
'default': false,
'note': __('fortnite-allow-stw-mode'),
},
// Deprecated
/*
[Preferences.DEPRECATED_USE_DESKTOP_CODEC]: {
@ -7239,12 +7283,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) {
@ -7285,6 +7329,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();
@ -7313,6 +7358,18 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
funcStr = funcStr.replace(text, 'window.BX_EXPOSED["touch_layout_manager"] = this,' + text);
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 = [
@ -7326,13 +7383,13 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
getPref(Preferences.UI_LAYOUT) === 'tv' && ['tvLayout'],
ENABLE_XCLOUD_LOGGER && [
'enableXcloudLogger',
'enableConsoleLogging',
'enableXcloudLogger',
],
getPref(Preferences.BLOCK_TRACKING) && [
'disableTrackEvent',
'blockWebRtcStatsCollector',
'disableTrackEvent',
],
getPref(Preferences.REMOTE_PLAY_ENABLED) && [
@ -7345,6 +7402,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
@ -8993,9 +9052,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',
]);
}
@ -9072,6 +9132,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);
}
@ -9399,17 +9470,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);
}
}
@ -9511,6 +9571,7 @@ function injectSettingsButton($parent) {
[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'),
[Preferences.GAME_FORTNITE_FORCE_CONSOLE]: '🎮 ' + __('fortnite-force-console-version'),
},
[__('mouse-and-keyboard')]: {
@ -10353,7 +10414,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();
},
@ -10758,6 +10819,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;
}
@ -10805,6 +10867,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;
}