mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-29 19:01:43 +02:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
1f632db6b4 | |||
c07e3297ca | |||
5e43915ff7 | |||
e21375821d | |||
6438e533d6 | |||
e9671cbe5d | |||
b99ec65cc9 | |||
addcf56abf | |||
db17bda673 | |||
0a60119c3b | |||
ef14c78941 | |||
f2dc102996 | |||
02db103a72 | |||
f291047b64 | |||
5866644673 |
2
dist/better-xcloud.meta.js
vendored
2
dist/better-xcloud.meta.js
vendored
@ -1,5 +1,5 @@
|
||||
// ==UserScript==
|
||||
// @name Better xCloud
|
||||
// @namespace https://github.com/redphx
|
||||
// @version 4.6.0
|
||||
// @version 4.6.2
|
||||
// ==/UserScript==
|
||||
|
64
dist/better-xcloud.user.js
vendored
64
dist/better-xcloud.user.js
vendored
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name Better xCloud
|
||||
// @namespace https://github.com/redphx
|
||||
// @version 4.6.0
|
||||
// @version 4.6.2
|
||||
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
||||
// @author redphx
|
||||
// @license MIT
|
||||
@ -104,7 +104,7 @@ class UserAgent {
|
||||
}
|
||||
|
||||
// src/utils/global.ts
|
||||
var SCRIPT_VERSION = "4.6.0";
|
||||
var SCRIPT_VERSION = "4.6.2";
|
||||
var SCRIPT_HOME = "https://github.com/redphx/better-xcloud";
|
||||
var AppInterface = window.AppInterface;
|
||||
UserAgent.init();
|
||||
@ -1895,10 +1895,10 @@ class Preferences {
|
||||
migrate: function(savedPrefs, value) {
|
||||
try {
|
||||
value = parseInt(value);
|
||||
if (value < 100) {
|
||||
if (value !== 0 && value < 100) {
|
||||
value *= 1024000;
|
||||
}
|
||||
this.set(PrefKey.BITRATE_VIDEO_MAX, value);
|
||||
this.set(PrefKey.BITRATE_VIDEO_MAX, value, true);
|
||||
savedPrefs[PrefKey.BITRATE_VIDEO_MAX] = value;
|
||||
} catch (e) {
|
||||
}
|
||||
@ -2206,10 +2206,10 @@ class Preferences {
|
||||
const savedPrefs = JSON.parse(savedPrefsStr);
|
||||
for (let settingId in Preferences.SETTINGS) {
|
||||
const setting = Preferences.SETTINGS[settingId];
|
||||
setting.ready && setting.ready.call(this, setting);
|
||||
if (setting.migrate && settingId in savedPrefs) {
|
||||
setting.migrate.call(this, savedPrefs, savedPrefs[settingId]);
|
||||
}
|
||||
setting.ready && setting.ready.call(this, setting);
|
||||
}
|
||||
for (let settingId in Preferences.SETTINGS) {
|
||||
const setting = Preferences.SETTINGS[settingId];
|
||||
@ -2270,10 +2270,10 @@ class Preferences {
|
||||
}
|
||||
return this.#prefs[key];
|
||||
}
|
||||
set(key, value) {
|
||||
set(key, value, skipSave) {
|
||||
value = this.#validateValue(key, value);
|
||||
this.#prefs[key] = value;
|
||||
this.#updateStorage();
|
||||
!skipSave && this.#updateStorage();
|
||||
return value;
|
||||
}
|
||||
#updateStorage() {
|
||||
@ -3274,15 +3274,23 @@ class MkbHandler {
|
||||
}
|
||||
this.#mouseDataProvider.init();
|
||||
window.addEventListener("keydown", this.#onKeyboardEvent);
|
||||
this.#$message = CE("div", { class: "bx-mkb-pointer-lock-msg bx-gone" }, createButton({
|
||||
this.#$message = CE("div", { class: "bx-mkb-pointer-lock-msg bx-gone" }, CE("div", {}, CE("p", {}, t("mkb-click-to-activate")), CE("p", {}, t("press-key-to-toggle-mkb", { key: "F8" }))), CE("div", {}, createButton({
|
||||
icon: BxIcon.MOUSE_SETTINGS,
|
||||
label: t("edit"),
|
||||
style: ButtonStyle.PRIMARY,
|
||||
onClick: (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
showStreamSettings("mkb");
|
||||
}
|
||||
}), CE("div", {}, CE("p", {}, t("mkb-click-to-activate")), CE("p", {}, t("press-key-to-toggle-mkb", { key: "F8" }))));
|
||||
}), createButton({
|
||||
label: t("disable"),
|
||||
onClick: (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.toggle();
|
||||
}
|
||||
})));
|
||||
this.#$message.addEventListener("click", this.start.bind(this));
|
||||
document.documentElement.appendChild(this.#$message);
|
||||
window.addEventListener(BxEvent.XCLOUD_POLLING_MODE_CHANGED, this.#onPollingModeChanged);
|
||||
@ -3780,6 +3788,7 @@ var BxExposed = {
|
||||
}
|
||||
if (touchControllerAvailability === "off") {
|
||||
supportedInputTypes = supportedInputTypes.filter((i) => i !== InputType.CUSTOM_TOUCH_OVERLAY && i !== InputType.GENERIC_TOUCH);
|
||||
titleInfo.details.supportedTabs = [];
|
||||
}
|
||||
titleInfo.details.hasTouchSupport = supportedInputTypes.includes(InputType.NATIVE_TOUCH) || supportedInputTypes.includes(InputType.CUSTOM_TOUCH_OVERLAY) || supportedInputTypes.includes(InputType.GENERIC_TOUCH);
|
||||
if (!titleInfo.details.hasTouchSupport && touchControllerAvailability === "all") {
|
||||
@ -3877,6 +3886,10 @@ class LoadingScreen {
|
||||
#game-stream div[class*=RocketAnimation-module__container] > svg {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#game-stream video[class*=RocketAnimationVideo-module__video] {
|
||||
display: none;
|
||||
}
|
||||
`;
|
||||
$bgStyle.textContent += css;
|
||||
}
|
||||
@ -3965,8 +3978,8 @@ class LoadingScreen {
|
||||
LoadingScreen.reset();
|
||||
}
|
||||
static reset() {
|
||||
LoadingScreen.#$bgStyle && setTimeout(() => LoadingScreen.#$bgStyle.textContent = "", 2000);
|
||||
LoadingScreen.#$waitTimeBox && LoadingScreen.#$waitTimeBox.classList.add("bx-gone");
|
||||
LoadingScreen.#$bgStyle && (LoadingScreen.#$bgStyle.textContent = "");
|
||||
LoadingScreen.#waitTimeInterval && clearInterval(LoadingScreen.#waitTimeInterval);
|
||||
LoadingScreen.#waitTimeInterval = null;
|
||||
}
|
||||
@ -5107,8 +5120,8 @@ var resizeVideoPlayer = function() {
|
||||
width = parentRect.width;
|
||||
height = width / videoRatio;
|
||||
}
|
||||
width = Math.floor(width);
|
||||
height = Math.floor(height);
|
||||
width = Math.min(parentRect.width, Math.ceil(width));
|
||||
height = Math.min(parentRect.height, Math.ceil(height));
|
||||
$video.style.width = `${width}px`;
|
||||
$video.style.height = `${height}px`;
|
||||
$video.style.objectFit = "fill";
|
||||
@ -6051,7 +6064,7 @@ div[class*=NotFocusedDialog] {
|
||||
height: var(--bx-button-height);
|
||||
line-height: var(--bx-button-height);
|
||||
vertical-align: middle;
|
||||
vertical-align: -webkit-baseline-middle;
|
||||
/* vertical-align: -webkit-baseline-middle; */
|
||||
color: #fff;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
@ -7011,7 +7024,6 @@ div[data-testid=media-container].bx-taking-screenshot:before {
|
||||
color: #fff;
|
||||
}
|
||||
.bx-mkb-pointer-lock-msg {
|
||||
display: flex;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
@ -7035,14 +7047,7 @@ div[data-testid=media-container].bx-taking-screenshot:before {
|
||||
.bx-mkb-pointer-lock-msg:hover {
|
||||
background: #151515;
|
||||
}
|
||||
.bx-mkb-pointer-lock-msg button {
|
||||
margin-right: 12px;
|
||||
height: 60px;
|
||||
}
|
||||
.bx-mkb-pointer-lock-msg svg {
|
||||
width: 32px;
|
||||
}
|
||||
.bx-mkb-pointer-lock-msg div {
|
||||
.bx-mkb-pointer-lock-msg > div:first-of-type {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
text-align: left;
|
||||
@ -7058,6 +7063,21 @@ div[data-testid=media-container].bx-taking-screenshot:before {
|
||||
font-size: 14px;
|
||||
font-style: italic;
|
||||
}
|
||||
.bx-mkb-pointer-lock-msg > div:last-of-type {
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
margin-top: 10px;
|
||||
button
|
||||
}
|
||||
.bx-mkb-pointer-lock-msg > div:last-of-type button {
|
||||
flex: 1;
|
||||
}
|
||||
.bx-mkb-pointer-lock-msg > div:last-of-type button:first-of-type {
|
||||
margin-right: 5px;
|
||||
}
|
||||
.bx-mkb-pointer-lock-msg > div:last-of-type button:last-of-type {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.bx-mkb-preset-tools {
|
||||
display: flex;
|
||||
margin-bottom: 12px;
|
||||
|
@ -74,7 +74,7 @@
|
||||
height: var(--bx-button-height);
|
||||
line-height: var(--bx-button-height);
|
||||
vertical-align: middle;
|
||||
vertical-align: -webkit-baseline-middle;
|
||||
/* vertical-align: -webkit-baseline-middle; */
|
||||
color: #fff;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
|
@ -16,7 +16,6 @@
|
||||
}
|
||||
|
||||
.bx-mkb-pointer-lock-msg {
|
||||
display: flex;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
@ -41,16 +40,7 @@
|
||||
background: #151515;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-right: 12px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
svg {
|
||||
width: 32px;
|
||||
}
|
||||
|
||||
div {
|
||||
> div:first-of-type {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
text-align: left;
|
||||
@ -69,6 +59,26 @@
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
||||
> div:last-of-type {
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
margin-top: 10px;
|
||||
|
||||
button {
|
||||
flex: 1;
|
||||
|
||||
&:first-of-type {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
&:last-of-type {
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
button
|
||||
}
|
||||
}
|
||||
|
||||
.bx-mkb-preset-tools {
|
||||
|
@ -46,6 +46,10 @@ export class LoadingScreen {
|
||||
#game-stream div[class*=RocketAnimation-module__container] > svg {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#game-stream video[class*=RocketAnimationVideo-module__video] {
|
||||
display: none;
|
||||
}
|
||||
`;
|
||||
$bgStyle.textContent += css;
|
||||
}
|
||||
@ -163,9 +167,9 @@ export class LoadingScreen {
|
||||
}
|
||||
|
||||
static reset() {
|
||||
LoadingScreen.#$waitTimeBox && LoadingScreen.#$waitTimeBox.classList.add('bx-gone');
|
||||
LoadingScreen.#$bgStyle && (LoadingScreen.#$bgStyle.textContent = '');
|
||||
LoadingScreen.#$bgStyle && setTimeout(() => LoadingScreen.#$bgStyle.textContent = '', 2000);
|
||||
|
||||
LoadingScreen.#$waitTimeBox && LoadingScreen.#$waitTimeBox.classList.add('bx-gone');
|
||||
LoadingScreen.#waitTimeInterval && clearInterval(LoadingScreen.#waitTimeInterval);
|
||||
LoadingScreen.#waitTimeInterval = null;
|
||||
}
|
||||
|
@ -464,20 +464,34 @@ export class MkbHandler {
|
||||
window.addEventListener('keydown', this.#onKeyboardEvent);
|
||||
|
||||
this.#$message = CE('div', {'class': 'bx-mkb-pointer-lock-msg bx-gone'},
|
||||
createButton({
|
||||
icon: BxIcon.MOUSE_SETTINGS,
|
||||
style: ButtonStyle.PRIMARY,
|
||||
onClick: e => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
showStreamSettings('mkb');
|
||||
},
|
||||
}),
|
||||
CE('div', {},
|
||||
CE('p', {}, t('mkb-click-to-activate')),
|
||||
CE('p', {}, t('press-key-to-toggle-mkb', {key: 'F8'})),
|
||||
),
|
||||
|
||||
CE('div', {},
|
||||
createButton({
|
||||
icon: BxIcon.MOUSE_SETTINGS,
|
||||
label: t('edit'),
|
||||
style: ButtonStyle.PRIMARY,
|
||||
onClick: e => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
showStreamSettings('mkb');
|
||||
},
|
||||
}),
|
||||
|
||||
createButton({
|
||||
label: t('disable'),
|
||||
onClick: e => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
this.toggle();
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
this.#$message.addEventListener('click', this.start.bind(this));
|
||||
|
@ -485,8 +485,8 @@ function resizeVideoPlayer() {
|
||||
}
|
||||
|
||||
// Prevent floating points
|
||||
width = Math.floor(width);
|
||||
height = Math.floor(height);
|
||||
width = Math.min(parentRect.width, Math.ceil(width));
|
||||
height = Math.min(parentRect.height, Math.ceil(height));
|
||||
|
||||
// Update size
|
||||
$video.style.width = `${width}px`;
|
||||
|
1
src/types/index.d.ts
vendored
1
src/types/index.d.ts
vendored
@ -59,6 +59,7 @@ type XcloudTitleInfo = {
|
||||
details: {
|
||||
productId: string;
|
||||
supportedInputTypes: InputType[];
|
||||
supportedTabs: any[];
|
||||
hasTouchSupport: boolean;
|
||||
hasFakeTouchSupport: boolean;
|
||||
hasMkbSupport: boolean;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { ControllerShortcut } from "@/modules/controller-shortcut";
|
||||
import { GameBar } from "@modules/game-bar/game-bar";
|
||||
import { BxEvent } from "@utils/bx-event";
|
||||
import { STATES } from "@utils/global";
|
||||
import { getPref, PrefKey } from "@utils/preferences";
|
||||
@ -49,11 +48,11 @@ export const BxExposed = {
|
||||
gamepadFound && (touchControllerAvailability = 'off');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (touchControllerAvailability === 'off') {
|
||||
// Disable touch on all games (not native touch)
|
||||
supportedInputTypes = supportedInputTypes.filter(i => i !== InputType.CUSTOM_TOUCH_OVERLAY && i !== InputType.GENERIC_TOUCH);
|
||||
// Empty TABs
|
||||
titleInfo.details.supportedTabs = [];
|
||||
}
|
||||
|
||||
// Pre-check supported input types
|
||||
|
@ -344,11 +344,10 @@ export class Preferences {
|
||||
migrate: function(savedPrefs: any, value: any) {
|
||||
try {
|
||||
value = parseInt(value);
|
||||
if (value < 100) {
|
||||
if (value !== 0 && value < 100) {
|
||||
value *= 1024 * 1000;
|
||||
}
|
||||
|
||||
this.set(PrefKey.BITRATE_VIDEO_MAX, value);
|
||||
this.set(PrefKey.BITRATE_VIDEO_MAX, value, true);
|
||||
savedPrefs[PrefKey.BITRATE_VIDEO_MAX] = value;
|
||||
} catch (e) {}
|
||||
},
|
||||
@ -701,11 +700,12 @@ export class Preferences {
|
||||
|
||||
for (let settingId in Preferences.SETTINGS) {
|
||||
const setting = Preferences.SETTINGS[settingId];
|
||||
setting.ready && setting.ready.call(this, setting);
|
||||
|
||||
if (setting.migrate && settingId in savedPrefs) {
|
||||
setting.migrate.call(this, savedPrefs, savedPrefs[settingId]);
|
||||
}
|
||||
|
||||
setting.ready && setting.ready.call(this, setting);
|
||||
}
|
||||
|
||||
for (let settingId in Preferences.SETTINGS) {
|
||||
@ -716,7 +716,7 @@ export class Preferences {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore deprecated settings
|
||||
// Ignore deprecated/migrated settings
|
||||
if (setting.migrate) {
|
||||
continue;
|
||||
}
|
||||
@ -783,11 +783,11 @@ export class Preferences {
|
||||
return this.#prefs[key];
|
||||
}
|
||||
|
||||
set(key: PrefKey, value: any): any {
|
||||
set(key: PrefKey, value: any, skipSave?: boolean): any {
|
||||
value = this.#validateValue(key, value);
|
||||
|
||||
this.#prefs[key] = value;
|
||||
this.#updateStorage();
|
||||
!skipSave && this.#updateStorage();
|
||||
|
||||
return value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user