mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 08:07:18 +02:00
Update better-xcloud.user.js
This commit is contained in:
parent
c7734245ae
commit
d8b9fcc951
71
dist/better-xcloud.user.js
vendored
71
dist/better-xcloud.user.js
vendored
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 4.7.0
|
// @version 4.7.1-beta
|
||||||
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
||||||
// @author redphx
|
// @author redphx
|
||||||
// @license MIT
|
// @license MIT
|
||||||
@ -104,7 +104,7 @@ class UserAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/utils/global.ts
|
// src/utils/global.ts
|
||||||
var SCRIPT_VERSION = "4.7.0";
|
var SCRIPT_VERSION = "4.7.1-beta";
|
||||||
var SCRIPT_HOME = "https://github.com/redphx/better-xcloud";
|
var SCRIPT_HOME = "https://github.com/redphx/better-xcloud";
|
||||||
var AppInterface = window.AppInterface;
|
var AppInterface = window.AppInterface;
|
||||||
UserAgent.init();
|
UserAgent.init();
|
||||||
@ -112,15 +112,16 @@ var userAgent = window.navigator.userAgent.toLowerCase();
|
|||||||
var isTv = userAgent.includes("smart-tv") || userAgent.includes("smarttv") || /\baft.*\b/.test(userAgent);
|
var isTv = userAgent.includes("smart-tv") || userAgent.includes("smarttv") || /\baft.*\b/.test(userAgent);
|
||||||
var isVr = window.navigator.userAgent.includes("VR") && window.navigator.userAgent.includes("OculusBrowser");
|
var isVr = window.navigator.userAgent.includes("VR") && window.navigator.userAgent.includes("OculusBrowser");
|
||||||
var browserHasTouchSupport = "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
var browserHasTouchSupport = "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
||||||
var hasTouchSupport = !isTv && !isVr && browserHasTouchSupport;
|
var userAgentHasTouchSupport = !isTv && !isVr && browserHasTouchSupport;
|
||||||
var STATES = {
|
var STATES = {
|
||||||
isPlaying: false,
|
isPlaying: false,
|
||||||
appContext: {},
|
appContext: {},
|
||||||
serverRegions: {},
|
serverRegions: {},
|
||||||
hasTouchSupport,
|
userAgentHasTouchSupport,
|
||||||
browserHasTouchSupport,
|
browserHasTouchSupport,
|
||||||
currentStream: {},
|
currentStream: {},
|
||||||
remotePlay: {}
|
remotePlay: {},
|
||||||
|
pointerServerPort: 9269
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/utils/bx-event.ts
|
// src/utils/bx-event.ts
|
||||||
@ -1590,7 +1591,7 @@ class Preferences {
|
|||||||
all: t("tc-all-games"),
|
all: t("tc-all-games"),
|
||||||
off: t("off")
|
off: t("off")
|
||||||
},
|
},
|
||||||
unsupported: !STATES.hasTouchSupport,
|
unsupported: !STATES.userAgentHasTouchSupport,
|
||||||
ready: (setting) => {
|
ready: (setting) => {
|
||||||
if (setting.unsupported) {
|
if (setting.unsupported) {
|
||||||
setting.default = "default";
|
setting.default = "default";
|
||||||
@ -1600,7 +1601,7 @@ class Preferences {
|
|||||||
[PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF]: {
|
[PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF]: {
|
||||||
label: t("tc-auto-off"),
|
label: t("tc-auto-off"),
|
||||||
default: false,
|
default: false,
|
||||||
unsupported: !STATES.hasTouchSupport
|
unsupported: !STATES.userAgentHasTouchSupport
|
||||||
},
|
},
|
||||||
[PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY]: {
|
[PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY]: {
|
||||||
type: SettingElementType.NUMBER_STEPPER,
|
type: SettingElementType.NUMBER_STEPPER,
|
||||||
@ -1614,7 +1615,7 @@ class Preferences {
|
|||||||
ticks: 10,
|
ticks: 10,
|
||||||
hideSlider: true
|
hideSlider: true
|
||||||
},
|
},
|
||||||
unsupported: !STATES.hasTouchSupport
|
unsupported: !STATES.userAgentHasTouchSupport
|
||||||
},
|
},
|
||||||
[PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_STANDARD]: {
|
[PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_STANDARD]: {
|
||||||
label: t("tc-standard-layout-style"),
|
label: t("tc-standard-layout-style"),
|
||||||
@ -1624,7 +1625,7 @@ class Preferences {
|
|||||||
white: t("tc-all-white"),
|
white: t("tc-all-white"),
|
||||||
muted: t("tc-muted-colors")
|
muted: t("tc-muted-colors")
|
||||||
},
|
},
|
||||||
unsupported: !STATES.hasTouchSupport
|
unsupported: !STATES.userAgentHasTouchSupport
|
||||||
},
|
},
|
||||||
[PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_CUSTOM]: {
|
[PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_CUSTOM]: {
|
||||||
label: t("tc-custom-layout-style"),
|
label: t("tc-custom-layout-style"),
|
||||||
@ -1633,7 +1634,7 @@ class Preferences {
|
|||||||
default: t("default"),
|
default: t("default"),
|
||||||
muted: t("tc-muted-colors")
|
muted: t("tc-muted-colors")
|
||||||
},
|
},
|
||||||
unsupported: !STATES.hasTouchSupport
|
unsupported: !STATES.userAgentHasTouchSupport
|
||||||
},
|
},
|
||||||
[PrefKey.STREAM_SIMPLIFY_MENU]: {
|
[PrefKey.STREAM_SIMPLIFY_MENU]: {
|
||||||
label: t("simplify-stream-menu"),
|
label: t("simplify-stream-menu"),
|
||||||
@ -1842,7 +1843,7 @@ class Preferences {
|
|||||||
},
|
},
|
||||||
[PrefKey.UI_HOME_CONTEXT_MENU_DISABLED]: {
|
[PrefKey.UI_HOME_CONTEXT_MENU_DISABLED]: {
|
||||||
label: t("disable-home-context-menu"),
|
label: t("disable-home-context-menu"),
|
||||||
default: false
|
default: STATES.browserHasTouchSupport
|
||||||
},
|
},
|
||||||
[PrefKey.BLOCK_SOCIAL_FEATURES]: {
|
[PrefKey.BLOCK_SOCIAL_FEATURES]: {
|
||||||
label: t("disable-social-features"),
|
label: t("disable-social-features"),
|
||||||
@ -2968,7 +2969,6 @@ var PointerAction;
|
|||||||
})(PointerAction || (PointerAction = {}));
|
})(PointerAction || (PointerAction = {}));
|
||||||
|
|
||||||
class PointerClient {
|
class PointerClient {
|
||||||
static #PORT = 9269;
|
|
||||||
static instance;
|
static instance;
|
||||||
static getInstance() {
|
static getInstance() {
|
||||||
if (!PointerClient.instance) {
|
if (!PointerClient.instance) {
|
||||||
@ -2978,9 +2978,12 @@ class PointerClient {
|
|||||||
}
|
}
|
||||||
#socket;
|
#socket;
|
||||||
#mkbHandler;
|
#mkbHandler;
|
||||||
start(mkbHandler) {
|
start(port, mkbHandler) {
|
||||||
|
if (!port) {
|
||||||
|
throw new Error("PointerServer port is 0");
|
||||||
|
}
|
||||||
this.#mkbHandler = mkbHandler;
|
this.#mkbHandler = mkbHandler;
|
||||||
this.#socket = new WebSocket(`ws://localhost:${PointerClient.#PORT}`);
|
this.#socket = new WebSocket(`ws://localhost:${port}`);
|
||||||
this.#socket.binaryType = "arraybuffer";
|
this.#socket.binaryType = "arraybuffer";
|
||||||
this.#socket.addEventListener("open", (event) => {
|
this.#socket.addEventListener("open", (event) => {
|
||||||
BxLogger.info(LOG_TAG, "connected");
|
BxLogger.info(LOG_TAG, "connected");
|
||||||
@ -3159,7 +3162,7 @@ class NativeMkbHandler extends MkbHandler {
|
|||||||
this.#inputSink = window.BX_EXPOSED.inputSink;
|
this.#inputSink = window.BX_EXPOSED.inputSink;
|
||||||
this.#updateInputConfigurationAsync(false);
|
this.#updateInputConfigurationAsync(false);
|
||||||
try {
|
try {
|
||||||
this.#pointerClient.start(this);
|
this.#pointerClient.start(STATES.pointerServerPort, this);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toast.show("Cannot enable Mouse & Keyboard feature");
|
Toast.show("Cannot enable Mouse & Keyboard feature");
|
||||||
}
|
}
|
||||||
@ -3313,7 +3316,7 @@ class WebSocketMouseDataProvider extends MouseDataProvider {
|
|||||||
this.#pointerClient = PointerClient.getInstance();
|
this.#pointerClient = PointerClient.getInstance();
|
||||||
this.#connected = false;
|
this.#connected = false;
|
||||||
try {
|
try {
|
||||||
this.#pointerClient.start(this.mkbHandler);
|
this.#pointerClient.start(STATES.pointerServerPort, this.mkbHandler);
|
||||||
this.#connected = true;
|
this.#connected = true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toast.show("Cannot enable Mouse & Keyboard feature");
|
Toast.show("Cannot enable Mouse & Keyboard feature");
|
||||||
@ -3837,6 +3840,9 @@ class StreamUiShortcut {
|
|||||||
|
|
||||||
// src/utils/utils.ts
|
// src/utils/utils.ts
|
||||||
function checkForUpdate() {
|
function checkForUpdate() {
|
||||||
|
if (SCRIPT_VERSION.includes("beta")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const CHECK_INTERVAL_SECONDS = 7200;
|
const CHECK_INTERVAL_SECONDS = 7200;
|
||||||
const currentVersion = getPref(PrefKey.CURRENT_VERSION);
|
const currentVersion = getPref(PrefKey.CURRENT_VERSION);
|
||||||
const lastCheck = getPref(PrefKey.LAST_UPDATE_CHECK);
|
const lastCheck = getPref(PrefKey.LAST_UPDATE_CHECK);
|
||||||
@ -4228,7 +4234,7 @@ var BxExposed = {
|
|||||||
supportedInputTypes = supportedInputTypes.filter((i) => i !== InputType.MKB);
|
supportedInputTypes = supportedInputTypes.filter((i) => i !== InputType.MKB);
|
||||||
}
|
}
|
||||||
titleInfo.details.hasMkbSupport = supportedInputTypes.includes(InputType.MKB);
|
titleInfo.details.hasMkbSupport = supportedInputTypes.includes(InputType.MKB);
|
||||||
if (STATES.hasTouchSupport) {
|
if (STATES.userAgentHasTouchSupport) {
|
||||||
let touchControllerAvailability = getPref(PrefKey.STREAM_TOUCH_CONTROLLER);
|
let touchControllerAvailability = getPref(PrefKey.STREAM_TOUCH_CONTROLLER);
|
||||||
if (touchControllerAvailability !== "off" && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) {
|
if (touchControllerAvailability !== "off" && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) {
|
||||||
const gamepads = window.navigator.getGamepads();
|
const gamepads = window.navigator.getGamepads();
|
||||||
@ -5333,7 +5339,7 @@ var setupStreamSettingsDialog = function() {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
STATES.hasTouchSupport && {
|
STATES.userAgentHasTouchSupport && {
|
||||||
group: "touch-controller",
|
group: "touch-controller",
|
||||||
label: t("touch-controller"),
|
label: t("touch-controller"),
|
||||||
items: [
|
items: [
|
||||||
@ -6055,7 +6061,7 @@ function interceptHttpRequests() {
|
|||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (STATES.hasTouchSupport && url.includes("catalog.gamepass.com/sigls/")) {
|
if (STATES.userAgentHasTouchSupport && url.includes("catalog.gamepass.com/sigls/")) {
|
||||||
const response = await NATIVE_FETCH(request, init);
|
const response = await NATIVE_FETCH(request, init);
|
||||||
const obj = await response.clone().json();
|
const obj = await response.clone().json();
|
||||||
if (url.includes(GamePassCloudGallery.ALL)) {
|
if (url.includes(GamePassCloudGallery.ALL)) {
|
||||||
@ -6149,12 +6155,12 @@ class XhomeInterceptor {
|
|||||||
const xboxTitleId = JSON.parse(opts.body).titleIds[0];
|
const xboxTitleId = JSON.parse(opts.body).titleIds[0];
|
||||||
STATES.currentStream.xboxTitleId = xboxTitleId;
|
STATES.currentStream.xboxTitleId = xboxTitleId;
|
||||||
const inputConfigs = obj[0];
|
const inputConfigs = obj[0];
|
||||||
let hasTouchSupport2 = inputConfigs.supportedTabs.length > 0;
|
let hasTouchSupport = inputConfigs.supportedTabs.length > 0;
|
||||||
if (!hasTouchSupport2) {
|
if (!hasTouchSupport) {
|
||||||
const supportedInputTypes = inputConfigs.supportedInputTypes;
|
const supportedInputTypes = inputConfigs.supportedInputTypes;
|
||||||
hasTouchSupport2 = supportedInputTypes.includes(InputType.NATIVE_TOUCH) || supportedInputTypes.includes(InputType.CUSTOM_TOUCH_OVERLAY);
|
hasTouchSupport = supportedInputTypes.includes(InputType.NATIVE_TOUCH) || supportedInputTypes.includes(InputType.CUSTOM_TOUCH_OVERLAY);
|
||||||
}
|
}
|
||||||
if (hasTouchSupport2) {
|
if (hasTouchSupport) {
|
||||||
TouchController.disable();
|
TouchController.disable();
|
||||||
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
||||||
data: null
|
data: null
|
||||||
@ -8356,7 +8362,7 @@ var PATCH_ORDERS = [
|
|||||||
"remotePlayKeepAlive",
|
"remotePlayKeepAlive",
|
||||||
"remotePlayDirectConnectUrl",
|
"remotePlayDirectConnectUrl",
|
||||||
"remotePlayDisableAchievementToast",
|
"remotePlayDisableAchievementToast",
|
||||||
STATES.hasTouchSupport && "patchUpdateInputConfigurationAsync"
|
STATES.userAgentHasTouchSupport && "patchUpdateInputConfigurationAsync"
|
||||||
] : [],
|
] : [],
|
||||||
...BX_FLAGS.EnableXcloudLogging ? [
|
...BX_FLAGS.EnableXcloudLogging ? [
|
||||||
"enableConsoleLogging",
|
"enableConsoleLogging",
|
||||||
@ -8371,7 +8377,7 @@ var PLAYING_PATCH_ORDERS = [
|
|||||||
getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && !getPref(PrefKey.STREAM_COMBINE_SOURCES) && "patchAudioMediaStream",
|
getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && !getPref(PrefKey.STREAM_COMBINE_SOURCES) && "patchAudioMediaStream",
|
||||||
getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && getPref(PrefKey.STREAM_COMBINE_SOURCES) && "patchCombinedAudioVideoMediaStream",
|
getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && getPref(PrefKey.STREAM_COMBINE_SOURCES) && "patchCombinedAudioVideoMediaStream",
|
||||||
getPref(PrefKey.STREAM_DISABLE_FEEDBACK_DIALOG) && "skipFeedbackDialog",
|
getPref(PrefKey.STREAM_DISABLE_FEEDBACK_DIALOG) && "skipFeedbackDialog",
|
||||||
...STATES.hasTouchSupport ? [
|
...STATES.userAgentHasTouchSupport ? [
|
||||||
getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === "all" && "patchShowSensorControls",
|
getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === "all" && "patchShowSensorControls",
|
||||||
getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === "all" && "exposeTouchLayoutManager",
|
getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === "all" && "exposeTouchLayoutManager",
|
||||||
(getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === "off" || getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) && "disableTakRenderer",
|
(getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === "off" || getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) && "disableTakRenderer",
|
||||||
@ -8811,8 +8817,8 @@ var SETTINGS_UI = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
[t("touch-controller")]: {
|
[t("touch-controller")]: {
|
||||||
note: !STATES.hasTouchSupport ? "⚠️ " + t("device-unsupported-touch") : null,
|
note: !STATES.userAgentHasTouchSupport ? "⚠️ " + t("device-unsupported-touch") : null,
|
||||||
unsupported: !STATES.hasTouchSupport,
|
unsupported: !STATES.userAgentHasTouchSupport,
|
||||||
items: [
|
items: [
|
||||||
PrefKey.STREAM_TOUCH_CONTROLLER,
|
PrefKey.STREAM_TOUCH_CONTROLLER,
|
||||||
PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF,
|
PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF,
|
||||||
@ -8950,7 +8956,7 @@ function overridePreloadState() {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
BxLogger.error(LOG_TAG6, e);
|
BxLogger.error(LOG_TAG6, e);
|
||||||
}
|
}
|
||||||
if (STATES.hasTouchSupport) {
|
if (STATES.userAgentHasTouchSupport) {
|
||||||
try {
|
try {
|
||||||
const sigls = state.xcloud.sigls;
|
const sigls = state.xcloud.sigls;
|
||||||
if (GamePassCloudGallery.TOUCH in sigls) {
|
if (GamePassCloudGallery.TOUCH in sigls) {
|
||||||
@ -9339,7 +9345,7 @@ class GameBar {
|
|||||||
const $gameBar = CE("div", { id: "bx-game-bar", class: "bx-gone", "data-position": position }, $container = CE("div", { class: "bx-game-bar-container bx-offscreen" }), createSvgIcon(position === "bottom-left" ? BxIcon.CARET_RIGHT : BxIcon.CARET_LEFT));
|
const $gameBar = CE("div", { id: "bx-game-bar", class: "bx-gone", "data-position": position }, $container = CE("div", { class: "bx-game-bar-container bx-offscreen" }), createSvgIcon(position === "bottom-left" ? BxIcon.CARET_RIGHT : BxIcon.CARET_LEFT));
|
||||||
this.actions = [
|
this.actions = [
|
||||||
new ScreenshotAction,
|
new ScreenshotAction,
|
||||||
...STATES.hasTouchSupport && getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== "off" ? [new TouchControlAction] : [],
|
...STATES.userAgentHasTouchSupport && getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== "off" ? [new TouchControlAction] : [],
|
||||||
new MicrophoneAction
|
new MicrophoneAction
|
||||||
];
|
];
|
||||||
if (position === "bottom-right") {
|
if (position === "bottom-right") {
|
||||||
@ -9561,7 +9567,7 @@ var main = function() {
|
|||||||
AppInterface && patchPointerLockApi();
|
AppInterface && patchPointerLockApi();
|
||||||
getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && patchAudioContext();
|
getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && patchAudioContext();
|
||||||
getPref(PrefKey.BLOCK_TRACKING) && patchMeControl();
|
getPref(PrefKey.BLOCK_TRACKING) && patchMeControl();
|
||||||
STATES.hasTouchSupport && TouchController.updateCustomList();
|
STATES.userAgentHasTouchSupport && TouchController.updateCustomList();
|
||||||
overridePreloadState();
|
overridePreloadState();
|
||||||
VibrationManager.initialSetup();
|
VibrationManager.initialSetup();
|
||||||
BX_FLAGS.CheckForUpdate && checkForUpdate();
|
BX_FLAGS.CheckForUpdate && checkForUpdate();
|
||||||
@ -9583,7 +9589,10 @@ var main = function() {
|
|||||||
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === "all") {
|
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === "all") {
|
||||||
TouchController.setup();
|
TouchController.setup();
|
||||||
}
|
}
|
||||||
getPref(PrefKey.MKB_ENABLED) && AppInterface && AppInterface.startPointerServer();
|
if (getPref(PrefKey.MKB_ENABLED) && AppInterface) {
|
||||||
|
STATES.pointerServerPort = AppInterface.startPointerServer() || 9269;
|
||||||
|
BxLogger.info("startPointerServer", "Port", STATES.pointerServerPort.toString());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (window.location.pathname.includes("/auth/msa")) {
|
if (window.location.pathname.includes("/auth/msa")) {
|
||||||
window.addEventListener("load", (e) => {
|
window.addEventListener("load", (e) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user