mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-29 10:51:44 +02:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
d2ddc2fd23 | |||
a00b0b6879 | |||
83ff859798 | |||
0ef1e8a526 | |||
20caac4821 | |||
dac9823d5b | |||
bcdabbf1b9 | |||
11f3513b0c | |||
9786c7c8ee | |||
e48b277535 | |||
e2dbf873a6 | |||
6510eac0c3 | |||
3dd83ace6c | |||
45d8aed841 |
@ -1,5 +1,5 @@
|
||||
// ==UserScript==
|
||||
// @name Better xCloud
|
||||
// @namespace https://github.com/redphx
|
||||
// @version 3.1.6
|
||||
// @version 3.2
|
||||
// ==/UserScript==
|
||||
|
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name Better xCloud
|
||||
// @namespace https://github.com/redphx
|
||||
// @version 3.1.6
|
||||
// @version 3.2
|
||||
// @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.2';
|
||||
const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
|
||||
|
||||
const ENABLE_XCLOUD_LOGGER = false;
|
||||
@ -940,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",
|
||||
@ -1062,12 +1082,13 @@ const Translations = {
|
||||
"zh-CN": "快速",
|
||||
},
|
||||
"fortnite-allow-stw-mode": {
|
||||
"de-DE": "Spielen im \"STW\"-Modus auf Mobilgeräten erlauben",
|
||||
"en-US": "Allow playing STW mode on mobile",
|
||||
"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": "モバイル版での「世界を救え」を許可する",
|
||||
"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",
|
||||
@ -1076,9 +1097,10 @@ const Translations = {
|
||||
"de-DE": "Fortnite: Erzwinge Konsolenversion",
|
||||
"en-US": "Fortnite: force console version",
|
||||
"es-ES": "Fortnite: forzar versión de consola",
|
||||
"ja-JP": "Fortnite: 強制コンソールバージョン",
|
||||
"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",
|
||||
@ -6447,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'; }
|
||||
@ -6635,7 +6658,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];
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -6698,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,
|
||||
},
|
||||
@ -6735,9 +6766,19 @@ class Preferences {
|
||||
})(),
|
||||
'ready': () => {
|
||||
const pref = Preferences.SETTINGS[Preferences.MKB_ENABLED];
|
||||
const note = __(pref.unsupported ? 'browser-unsupported-feature' : 'mkb-disclaimer');
|
||||
|
||||
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: 'https://github.com/redphx/better-xcloud/issues/206#issuecomment-1920475657',
|
||||
href: url,
|
||||
target: '_blank',
|
||||
}, '⚠️ ' + note);
|
||||
},
|
||||
@ -6867,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')}`,
|
||||
@ -6884,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'),
|
||||
@ -7273,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) {
|
||||
@ -7319,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();
|
||||
|
||||
@ -7348,6 +7390,35 @@ if (window.BX_VIBRATION_INTENSITY && window.BX_VIBRATION_INTENSITY < 1) {
|
||||
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)) {
|
||||
@ -7372,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) && [
|
||||
@ -9041,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',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -9120,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);
|
||||
}
|
||||
@ -9447,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);
|
||||
}
|
||||
}
|
||||
@ -9556,10 +9630,11 @@ 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'),
|
||||
[Preferences.GAME_FORTNITE_FORCE_CONSOLE]: '🎮 ' + __('fortnite-force-console-version'),
|
||||
},
|
||||
|
||||
[__('mouse-and-keyboard')]: {
|
||||
@ -10402,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();
|
||||
},
|
||||
@ -10807,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;
|
||||
}
|
||||
|
||||
@ -10854,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