mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-06 13:18:27 +02:00
Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2d9ee16531 | ||
![]() |
21168803e0 | ||
![]() |
3068aa8a06 | ||
![]() |
b6b9ec49f6 | ||
![]() |
4dc60f965f | ||
![]() |
2142c4a83c | ||
![]() |
6b090194c9 | ||
![]() |
a878150ec3 | ||
![]() |
5fb1dded42 | ||
![]() |
ac6879c189 | ||
![]() |
b8efaf9648 | ||
![]() |
033ac31333 | ||
![]() |
1f754d4a1d | ||
![]() |
0d39ccf8bf | ||
![]() |
966d7f2f6c | ||
![]() |
fdbf618253 | ||
![]() |
aaa7612293 |
@@ -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.2
|
// @version 3.1.4
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 3.1.2
|
// @version 3.1.4
|
||||||
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
||||||
// @author redphx
|
// @author redphx
|
||||||
// @license MIT
|
// @license MIT
|
||||||
// @match https://www.xbox.com/*/play*
|
// @match https://www.xbox.com/*/play*
|
||||||
|
// @match https://www.xbox.com/*/auth/msa?*loggedIn*
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// @grant none
|
// @grant none
|
||||||
// @updateURL https://raw.githubusercontent.com/redphx/better-xcloud/main/better-xcloud.meta.js
|
// @updateURL https://raw.githubusercontent.com/redphx/better-xcloud/main/better-xcloud.meta.js
|
||||||
@@ -13,7 +14,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const SCRIPT_VERSION = '3.1.2';
|
const SCRIPT_VERSION = '3.1.4';
|
||||||
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;
|
||||||
@@ -38,6 +39,17 @@ window.NATIVE_MKB_TITLES = [
|
|||||||
// '9P731Z4BBCT3', // Atomic Heart
|
// '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}`);
|
console.log(`[Better xCloud] readyState: ${document.readyState}`);
|
||||||
|
|
||||||
const BxEvent = {
|
const BxEvent = {
|
||||||
@@ -49,6 +61,10 @@ const BxEvent = {
|
|||||||
STREAM_STARTED: 'bx-stream-started',
|
STREAM_STARTED: 'bx-stream-started',
|
||||||
STREAM_PLAYING: 'bx-stream-playing',
|
STREAM_PLAYING: 'bx-stream-playing',
|
||||||
STREAM_STOPPED: 'bx-stream-stopped',
|
STREAM_STOPPED: 'bx-stream-stopped',
|
||||||
|
STREAM_ERROR_PAGE: 'bx-stream-error-page',
|
||||||
|
|
||||||
|
STREAM_MENU_SHOWN: 'bx-stream-menu-shown',
|
||||||
|
STREAM_MENU_HIDDEN: 'bx-stream-menu-hidden',
|
||||||
|
|
||||||
STREAM_WEBRTC_CONNECTED: 'bx-stream-webrtc-connected',
|
STREAM_WEBRTC_CONNECTED: 'bx-stream-webrtc-connected',
|
||||||
STREAM_WEBRTC_DISCONNECTED: 'bx-stream-webrtc-disconnected',
|
STREAM_WEBRTC_DISCONNECTED: 'bx-stream-webrtc-disconnected',
|
||||||
@@ -58,6 +74,11 @@ const BxEvent = {
|
|||||||
DATA_CHANNEL_CREATED: 'bx-data-channel-created',
|
DATA_CHANNEL_CREATED: 'bx-data-channel-created',
|
||||||
|
|
||||||
dispatch: (target, eventName, data) => {
|
dispatch: (target, eventName, data) => {
|
||||||
|
if (!eventName) {
|
||||||
|
alert('BxEvent.dispatch(): eventName is null');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const event = new Event(eventName);
|
const event = new Event(eventName);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -1311,6 +1332,7 @@ const Translations = {
|
|||||||
"pl-PL": "Używanie tej funkcji podczas grania online może być postrzegane jako oszukiwanie",
|
"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",
|
"pt-BR": "Usar esta função em jogos online pode ser considerado como uma forma de trapaça",
|
||||||
"ru-RU": "Использование этой функции при игре онлайн может рассматриваться как читерство",
|
"ru-RU": "Использование этой функции при игре онлайн может рассматриваться как читерство",
|
||||||
|
"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",
|
||||||
},
|
},
|
||||||
@@ -2451,6 +2473,15 @@ const Translations = {
|
|||||||
"vi-VN": "Phía trên bên phải",
|
"vi-VN": "Phía trên bên phải",
|
||||||
"zh-CN": "右上角",
|
"zh-CN": "右上角",
|
||||||
},
|
},
|
||||||
|
"touch-control-layout": {
|
||||||
|
"de-DE": "Touch-Steuerungslayout",
|
||||||
|
"en-US": "Touch control layout",
|
||||||
|
"ja-JP": "タッチコントロールレイアウト",
|
||||||
|
"pt-BR": "Layout do controle por toque",
|
||||||
|
"ru-RU": "Расположение сенсорных кнопок",
|
||||||
|
"uk-UA": "Розташування сенсорного керування",
|
||||||
|
"vi-VN": "Bố cục điều khiển cảm ứng",
|
||||||
|
},
|
||||||
"touch-controller": {
|
"touch-controller": {
|
||||||
"de-DE": "Touch-Controller",
|
"de-DE": "Touch-Controller",
|
||||||
"en-US": "Touch controller",
|
"en-US": "Touch controller",
|
||||||
@@ -3431,14 +3462,12 @@ class TouchController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static #show() {
|
static #show() {
|
||||||
document.querySelector('#BabylonCanvasContainer-main').parentElement.classList.remove('bx-gone');
|
document.querySelector('#BabylonCanvasContainer-main').parentElement.classList.remove('bx-offscreen');
|
||||||
// TouchController.loadCustomLayout(GAME_XBOX_TITLE_ID, TouchController.#currentLayoutId, 0);
|
|
||||||
TouchController.#showing = true;
|
TouchController.#showing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static #hide() {
|
static #hide() {
|
||||||
document.querySelector('#BabylonCanvasContainer-main').parentElement.classList.add('bx-gone');
|
document.querySelector('#BabylonCanvasContainer-main').parentElement.classList.add('bx-offscreen');
|
||||||
// TouchController.#dispatchMessage(TouchController.#EVENT_HIDE_CONTROLLER);
|
|
||||||
TouchController.#showing = false;
|
TouchController.#showing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3489,11 +3518,7 @@ class TouchController {
|
|||||||
url += `${xboxTitleId}.json`;
|
url += `${xboxTitleId}.json`;
|
||||||
}
|
}
|
||||||
NATIVE_FETCH(url)
|
NATIVE_FETCH(url)
|
||||||
.then(resp => resp.json(), () => {
|
.then(resp => resp.json())
|
||||||
TouchController.#customLayouts[xboxTitleId] = null;
|
|
||||||
// Wait for BX_EXPOSED.touch_layout_manager
|
|
||||||
setTimeout(() => dispatchLayouts(null), 1000);
|
|
||||||
})
|
|
||||||
.then(json => {
|
.then(json => {
|
||||||
// Normalize data
|
// Normalize data
|
||||||
const schema_version = json.schema_version || 1;
|
const schema_version = json.schema_version || 1;
|
||||||
@@ -3515,6 +3540,11 @@ class TouchController {
|
|||||||
|
|
||||||
// Wait for BX_EXPOSED.touch_layout_manager
|
// Wait for BX_EXPOSED.touch_layout_manager
|
||||||
setTimeout(() => dispatchLayouts(json), 1000);
|
setTimeout(() => dispatchLayouts(json), 1000);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
TouchController.#customLayouts[xboxTitleId] = null;
|
||||||
|
// Wait for BX_EXPOSED.touch_layout_manager
|
||||||
|
setTimeout(() => dispatchLayouts(null), 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3523,9 +3553,12 @@ class TouchController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const layoutChanged = TouchController.#currentLayoutId !== layoutId;
|
||||||
|
|
||||||
TouchController.#currentLayoutId = layoutId;
|
TouchController.#currentLayoutId = layoutId;
|
||||||
xboxTitleId = '' + xboxTitleId;
|
xboxTitleId = '' + xboxTitleId;
|
||||||
|
|
||||||
|
// Get layout data
|
||||||
const layoutData = TouchController.#customLayouts[xboxTitleId];
|
const layoutData = TouchController.#customLayouts[xboxTitleId];
|
||||||
if (!xboxTitleId || !layoutId || !layoutData) {
|
if (!xboxTitleId || !layoutId || !layoutData) {
|
||||||
TouchController.#enable && TouchController.#showDefault();
|
TouchController.#enable && TouchController.#showDefault();
|
||||||
@@ -3533,20 +3566,25 @@ class TouchController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const layout = (layoutData.layouts[layoutId] || layoutData.layouts[layoutData.default_layout]);
|
const layout = (layoutData.layouts[layoutId] || layoutData.layouts[layoutData.default_layout]);
|
||||||
layout && setTimeout(() => {
|
if (layout) {
|
||||||
window.BX_EXPOSED.touch_layout_manager.changeLayoutForScope({
|
// Show a toast with layout's name
|
||||||
type: 'showLayout',
|
layoutChanged && Toast.show(__('touch-control-layout'), layout.name);
|
||||||
scope: xboxTitleId,
|
|
||||||
subscope: 'base',
|
setTimeout(() => {
|
||||||
layout: {
|
window.BX_EXPOSED.touch_layout_manager.changeLayoutForScope({
|
||||||
id: 'System.Standard',
|
type: 'showLayout',
|
||||||
displayName: 'System',
|
scope: xboxTitleId,
|
||||||
layoutFile: {
|
subscope: 'base',
|
||||||
content: layout.content,
|
layout: {
|
||||||
},
|
id: 'System.Standard',
|
||||||
}
|
displayName: 'System',
|
||||||
});
|
layoutFile: {
|
||||||
}, delay);
|
content: layout.content,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static setup() {
|
static setup() {
|
||||||
@@ -3612,6 +3650,7 @@ class TouchController {
|
|||||||
setTimeout(TouchController.#show, 1000);
|
setTimeout(TouchController.#show, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let focused = false;
|
||||||
dataChannel.addEventListener('message', msg => {
|
dataChannel.addEventListener('message', msg => {
|
||||||
if (msg.origin === 'better-xcloud' || typeof msg.data !== 'string') {
|
if (msg.origin === 'better-xcloud' || typeof msg.data !== 'string') {
|
||||||
return;
|
return;
|
||||||
@@ -3619,7 +3658,13 @@ class TouchController {
|
|||||||
|
|
||||||
// Dispatch a message to display generic touch controller
|
// Dispatch a message to display generic touch controller
|
||||||
if (msg.data.includes('touchcontrols/showtitledefault')) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3629,6 +3674,7 @@ class TouchController {
|
|||||||
const json = JSON.parse(JSON.parse(msg.data).content);
|
const json = JSON.parse(JSON.parse(msg.data).content);
|
||||||
TouchController.#toggleBar(json.focused);
|
TouchController.#toggleBar(json.focused);
|
||||||
|
|
||||||
|
focused = json.focused;
|
||||||
if (!json.focused) {
|
if (!json.focused) {
|
||||||
TouchController.#show();
|
TouchController.#show();
|
||||||
}
|
}
|
||||||
@@ -4781,8 +4827,8 @@ class MkbHandler {
|
|||||||
this.#$message.addEventListener('click', this.#onActivatePointerLock);
|
this.#$message.addEventListener('click', this.#onActivatePointerLock);
|
||||||
document.documentElement.appendChild(this.#$message);
|
document.documentElement.appendChild(this.#$message);
|
||||||
|
|
||||||
window.addEventListener('bx-stream-menu-shown', this.#onStreamMenuShown);
|
window.addEventListener(BxEvent.STREAM_MENU_SHOWN, this.#onStreamMenuShown);
|
||||||
window.addEventListener('bx-stream-menu-hidden', this.#onStreamMenuHidden);
|
window.addEventListener(BxEvent.STREAM_MENU_HIDDEN, this.#onStreamMenuHidden);
|
||||||
|
|
||||||
this.#waitForPointerLock(true);
|
this.#waitForPointerLock(true);
|
||||||
}
|
}
|
||||||
@@ -4799,8 +4845,8 @@ class MkbHandler {
|
|||||||
document.removeEventListener('pointerlockchange', this.#onPointerLockChange);
|
document.removeEventListener('pointerlockchange', this.#onPointerLockChange);
|
||||||
document.removeEventListener('pointerlockerror', this.#onPointerLockError);
|
document.removeEventListener('pointerlockerror', this.#onPointerLockError);
|
||||||
|
|
||||||
window.removeEventListener('bx-stream-menu-shown', this.#onStreamMenuShown);
|
window.removeEventListener(BxEvent.STREAM_MENU_SHOWN, this.#onStreamMenuShown);
|
||||||
window.removeEventListener('bx-stream-menu-hidden', this.#onStreamMenuHidden);
|
window.removeEventListener(BxEvent.STREAM_MENU_HIDDEN, this.#onStreamMenuHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
start = () => {
|
start = () => {
|
||||||
@@ -6432,7 +6478,7 @@ class Preferences {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Preferences.STREAM_TARGET_RESOLUTION]: {
|
[Preferences.STREAM_TARGET_RESOLUTION]: {
|
||||||
'default': 'auto',
|
'default': '1080p',
|
||||||
'options': {
|
'options': {
|
||||||
'auto': __('default'),
|
'auto': __('default'),
|
||||||
'1080p': '1080p',
|
'1080p': '1080p',
|
||||||
@@ -6495,10 +6541,16 @@ class Preferences {
|
|||||||
return options;
|
return options;
|
||||||
})(),
|
})(),
|
||||||
'ready': () => {
|
'ready': () => {
|
||||||
const options = Preferences.SETTINGS[Preferences.STREAM_CODEC_PROFILE].options;
|
const setting = Preferences.SETTINGS[Preferences.STREAM_CODEC_PROFILE]
|
||||||
if (Object.keys(options).length <= 1) {
|
const options = setting.options;
|
||||||
Preferences.SETTINGS[Preferences.STREAM_CODEC_PROFILE].unsupported = true;
|
const keys = Object.keys(options);
|
||||||
Preferences.SETTINGS[Preferences.STREAM_CODEC_PROFILE].note = '⚠️ ' + __('browser-unsupported-feature');
|
|
||||||
|
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];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -6520,13 +6572,19 @@ class Preferences {
|
|||||||
'default': false,
|
'default': false,
|
||||||
},
|
},
|
||||||
[Preferences.STREAM_TOUCH_CONTROLLER]: {
|
[Preferences.STREAM_TOUCH_CONTROLLER]: {
|
||||||
'default': 'default',
|
'default': 'all',
|
||||||
'options': {
|
'options': {
|
||||||
'default': __('default'),
|
'default': __('default'),
|
||||||
'all': __('tc-all-games'),
|
'all': __('tc-all-games'),
|
||||||
'off': __('off'),
|
'off': __('off'),
|
||||||
},
|
},
|
||||||
'unsupported': !HAS_TOUCH_SUPPORT,
|
'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]: {
|
[Preferences.STREAM_TOUCH_CONTROLLER_STYLE_STANDARD]: {
|
||||||
'default': 'default',
|
'default': 'default',
|
||||||
@@ -6786,6 +6844,7 @@ class Preferences {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
|
/*
|
||||||
[Preferences.DEPRECATED_USE_DESKTOP_CODEC]: {
|
[Preferences.DEPRECATED_USE_DESKTOP_CODEC]: {
|
||||||
'default': false,
|
'default': false,
|
||||||
'migrate': function(savedPrefs, value) {
|
'migrate': function(savedPrefs, value) {
|
||||||
@@ -6794,6 +6853,7 @@ class Preferences {
|
|||||||
savedPrefs[Preferences.STREAM_CODEC_PROFILE] = quality;
|
savedPrefs[Preferences.STREAM_CODEC_PROFILE] = quality;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#storage = localStorage;
|
#storage = localStorage;
|
||||||
@@ -6808,12 +6868,14 @@ class Preferences {
|
|||||||
savedPrefs = JSON.parse(savedPrefs);
|
savedPrefs = JSON.parse(savedPrefs);
|
||||||
|
|
||||||
for (let settingId in Preferences.SETTINGS) {
|
for (let settingId in Preferences.SETTINGS) {
|
||||||
if (!(settingId in savedPrefs)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const setting = Preferences.SETTINGS[settingId];
|
const setting = Preferences.SETTINGS[settingId];
|
||||||
setting && setting.migrate && setting.migrate.call(this, savedPrefs, savedPrefs[settingId]);
|
setting.ready && setting.ready.call(this);
|
||||||
setting && 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) {
|
for (let settingId in Preferences.SETTINGS) {
|
||||||
@@ -8253,16 +8315,18 @@ div[class*=StreamMenu-module__menuContainer] > div[class*=Menu-module] {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
|
white-space: pre;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-toast-status {
|
.bx-toast-status {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 16px;
|
font-size: 14px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
background: #515863;
|
background: #515863;
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
white-space: pre;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx-number-stepper span {
|
.bx-number-stepper span {
|
||||||
@@ -9020,7 +9084,18 @@ function interceptHttpRequests() {
|
|||||||
|
|
||||||
return promise.then(response => {
|
return promise.then(response => {
|
||||||
return response.clone().json().then(obj => {
|
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();
|
TouchController.disable();
|
||||||
|
|
||||||
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
||||||
@@ -9028,9 +9103,6 @@ function interceptHttpRequests() {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
TouchController.enable();
|
TouchController.enable();
|
||||||
|
|
||||||
const xboxTitleId = JSON.parse(opts.body).titleIds[0];
|
|
||||||
GAME_XBOX_TITLE_ID = xboxTitleId;
|
|
||||||
TouchController.getCustomLayouts(xboxTitleId);
|
TouchController.getCustomLayouts(xboxTitleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9790,13 +9862,13 @@ function injectStreamMenuButtons() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
item.removedNodes.forEach($node => {
|
item.removedNodes.forEach($node => {
|
||||||
if (!$node.className || !$node.className.startsWith) {
|
if (!$node || !$node.className || !$node.className.startsWith) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($node.className.startsWith('StreamMenu')) {
|
if ($node.className.startsWith('StreamMenu')) {
|
||||||
if (!document.querySelector('div[class^=PureInStreamConfirmationModal]')) {
|
if (!document.querySelector('div[class^=PureInStreamConfirmationModal]')) {
|
||||||
window.dispatchEvent(new Event('bx-stream-menu-hidden'));
|
BxEvent.dispatch(window, BxEvent.STREAM_MENU_HIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -9806,6 +9878,12 @@ function injectStreamMenuButtons() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error Page: .PureErrorPage.ErrorScreen
|
||||||
|
if ($node.className.includes('PureErrorPage')) {
|
||||||
|
BxEvent.dispatch(window, BxEvent.STREAM_ERROR_PAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (PREF_DISABLE_FEEDBACK_DIALOG && $node.className.startsWith('PostStreamFeedbackScreen')) {
|
if (PREF_DISABLE_FEEDBACK_DIALOG && $node.className.startsWith('PostStreamFeedbackScreen')) {
|
||||||
const $btnClose = $node.querySelector('button');
|
const $btnClose = $node.querySelector('button');
|
||||||
$btnClose && $btnClose.click();
|
$btnClose && $btnClose.click();
|
||||||
@@ -9814,7 +9892,7 @@ function injectStreamMenuButtons() {
|
|||||||
|
|
||||||
// Render badges
|
// Render badges
|
||||||
if ($node.className.startsWith('StreamMenu')) {
|
if ($node.className.startsWith('StreamMenu')) {
|
||||||
window.dispatchEvent(new Event('bx-stream-menu-shown'));
|
BxEvent.dispatch(window, BxEvent.STREAM_MENU_SHOWN);
|
||||||
|
|
||||||
// Hide Quick bar when closing HUD
|
// Hide Quick bar when closing HUD
|
||||||
const $btnCloseHud = document.querySelector('button[class*=StreamMenu-module__backButton]');
|
const $btnCloseHud = document.querySelector('button[class*=StreamMenu-module__backButton]');
|
||||||
@@ -10456,14 +10534,10 @@ function patchHistoryMethod(type) {
|
|||||||
|
|
||||||
|
|
||||||
function onHistoryChanged(e) {
|
function onHistoryChanged(e) {
|
||||||
if (e.arguments && e.arguments[0] && e.arguments[0].origin === 'better-xcloud') {
|
if (e && e.arguments && e.arguments[0] && e.arguments[0].origin === 'better-xcloud') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop MKB listeners
|
|
||||||
MkbHandler.INSTANCE.destroy();
|
|
||||||
|
|
||||||
IS_PLAYING = false;
|
|
||||||
setTimeout(RemotePlay.detect, 10);
|
setTimeout(RemotePlay.detect, 10);
|
||||||
|
|
||||||
const $settings = document.querySelector('.better_xcloud_settings');
|
const $settings = document.querySelector('.better_xcloud_settings');
|
||||||
@@ -10471,28 +10545,10 @@ function onHistoryChanged(e) {
|
|||||||
$settings.classList.add('bx-gone');
|
$settings.classList.add('bx-gone');
|
||||||
}
|
}
|
||||||
|
|
||||||
const $quickBar = document.querySelector('.bx-quick-settings-bar');
|
|
||||||
if ($quickBar) {
|
|
||||||
$quickBar.classList.add('bx-gone');
|
|
||||||
}
|
|
||||||
|
|
||||||
STREAM_AUDIO_GAIN_NODE = null;
|
|
||||||
$STREAM_VIDEO = null;
|
|
||||||
StreamStats.onStoppedPlaying();
|
|
||||||
|
|
||||||
const $screenshotBtn = document.querySelector('.bx-screenshot-button');
|
|
||||||
if ($screenshotBtn) {
|
|
||||||
$screenshotBtn.style = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseCursorHider.stop();
|
|
||||||
TouchController.reset();
|
|
||||||
|
|
||||||
LoadingScreen.reset();
|
LoadingScreen.reset();
|
||||||
|
|
||||||
GamepadHandler.stopPolling();
|
|
||||||
|
|
||||||
setTimeout(checkHeader, 2000);
|
setTimeout(checkHeader, 2000);
|
||||||
|
|
||||||
|
BxEvent.dispatch(window, BxEvent.STREAM_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -10587,6 +10643,40 @@ window.addEventListener(BxEvent.STREAM_PLAYING, e => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener(BxEvent.STREAM_ERROR_PAGE, e => {
|
||||||
|
BxEvent.dispatch(window, BxEvent.STREAM_STOPPED);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener(BxEvent.STREAM_STOPPED, e => {
|
||||||
|
if (!IS_PLAYING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IS_PLAYING = false;
|
||||||
|
|
||||||
|
// Stop MKB listeners
|
||||||
|
MkbHandler.INSTANCE.destroy();
|
||||||
|
|
||||||
|
const $quickBar = document.querySelector('.bx-quick-settings-bar');
|
||||||
|
if ($quickBar) {
|
||||||
|
$quickBar.classList.add('bx-gone');
|
||||||
|
}
|
||||||
|
|
||||||
|
STREAM_AUDIO_GAIN_NODE = null;
|
||||||
|
$STREAM_VIDEO = null;
|
||||||
|
StreamStats.onStoppedPlaying();
|
||||||
|
|
||||||
|
const $screenshotBtn = document.querySelector('.bx-screenshot-button');
|
||||||
|
if ($screenshotBtn) {
|
||||||
|
$screenshotBtn.style = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseCursorHider.stop();
|
||||||
|
TouchController.reset();
|
||||||
|
|
||||||
|
GamepadHandler.stopPolling();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
PreloadedState.override();
|
PreloadedState.override();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user