mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-07-04 05:11:43 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
8ca6a9e08c | |||
344b6bb2c9 | |||
8b56ae218d | |||
3d2b887859 | |||
370fc7b2c2 | |||
5f4a1c24f0 | |||
382cd1aa51 | |||
d929a958ff |
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 5.5.4
|
||||
// @version 5.5.5
|
||||
// ==/UserScript==
|
||||
|
57
dist/better-xcloud.user.js
vendored
57
dist/better-xcloud.user.js
vendored
File diff suppressed because one or more lines are too long
@ -10,9 +10,9 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.1.6",
|
||||
"@types/node": "^20.14.14",
|
||||
"@types/node": "^20.14.15",
|
||||
"@types/stylus": "^0.48.42",
|
||||
"eslint": "^9.8.0",
|
||||
"eslint": "^9.9.0",
|
||||
"eslint-plugin-compat": "^6.0.0",
|
||||
"stylus": "^0.63.0"
|
||||
},
|
||||
|
@ -152,8 +152,8 @@
|
||||
bottom: offset;
|
||||
}
|
||||
|
||||
body[data-input-mode=Touch] &,
|
||||
body[data-input-mode=Mouse] & {
|
||||
html[data-active-input=touch] &,
|
||||
html[data-active-input=mouse] & {
|
||||
&:focus::after {
|
||||
border-color: transparent !important;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ document.addEventListener('readystatechange', e => {
|
||||
getPref(PrefKey.REMOTE_PLAY_ENABLED) && RemotePlay.preload();
|
||||
} else {
|
||||
// Show Settings button in the header when not signed in
|
||||
HeaderSection.watchHeader();
|
||||
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||
}
|
||||
|
||||
// Hide "Play with Friends" skeleton section
|
||||
@ -153,7 +153,7 @@ window.addEventListener(BxEvent.XCLOUD_SERVERS_UNAVAILABLE, e => {
|
||||
|
||||
window.addEventListener(BxEvent.XCLOUD_SERVERS_READY, e => {
|
||||
STATES.isSignedIn = true;
|
||||
HeaderSection.watchHeader();
|
||||
window.setTimeout(HeaderSection.watchHeader, 2000);
|
||||
});
|
||||
|
||||
window.addEventListener(BxEvent.STREAM_LOADING, e => {
|
||||
|
@ -392,9 +392,11 @@ if (window.BX_EXPOSED.stopTakRendering) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let remotePlayCode = '';
|
||||
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== 'off' && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) {
|
||||
remotePlayCode = `
|
||||
let autoOffCode = '';
|
||||
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'off') {
|
||||
autoOffCode = 'return;';
|
||||
} else if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) {
|
||||
autoOffCode = `
|
||||
const gamepads = window.navigator.getGamepads();
|
||||
let gamepadFound = false;
|
||||
|
||||
@ -412,13 +414,11 @@ if (gamepadFound) {
|
||||
}
|
||||
|
||||
const newCode = `
|
||||
if (!!window.BX_REMOTE_PLAY_CONFIG) {
|
||||
${remotePlayCode}
|
||||
} else {
|
||||
const titleInfo = window.BX_EXPOSED.getTitleInfo();
|
||||
if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFakeTouchSupport) {
|
||||
return;
|
||||
}
|
||||
${autoOffCode}
|
||||
|
||||
const titleInfo = window.BX_EXPOSED.getTitleInfo();
|
||||
if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFakeTouchSupport) {
|
||||
return;
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { GamepadKey } from "@/enums/mkb";
|
||||
import { EmulatedMkbHandler } from "@/modules/mkb/mkb-handler";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
import { STATES } from "@/utils/global";
|
||||
import { CE } from "@/utils/html";
|
||||
import { CE, isElementVisible } from "@/utils/html";
|
||||
import { setNearby } from "@/utils/navigation-utils";
|
||||
|
||||
export enum NavigationDirection {
|
||||
@ -519,11 +519,8 @@ export class NavigationDialogManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
const rect = $elm.getBoundingClientRect();
|
||||
const isVisible = !!rect.width && !!rect.height;
|
||||
|
||||
// Ignore hidden element
|
||||
if (!isVisible) {
|
||||
if (!isElementVisible($elm)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { SCRIPT_VERSION } from "@utils/global";
|
||||
import { createButton, ButtonStyle, CE } from "@utils/html";
|
||||
import { createButton, ButtonStyle, CE, isElementVisible } from "@utils/html";
|
||||
import { BxIcon } from "@utils/bx-icon";
|
||||
import { getPreferredServerRegion } from "@utils/region";
|
||||
import { RemotePlay } from "@modules/remote-play";
|
||||
@ -44,12 +44,16 @@ export class HeaderSection {
|
||||
const PREF_LATEST_VERSION = getPref(PrefKey.LATEST_VERSION);
|
||||
|
||||
// Setup Settings button
|
||||
const $settingsBtn = HeaderSection.#$settingsBtn;
|
||||
$settingsBtn.querySelector('span')!.textContent = getPreferredServerRegion(true) || t('better-xcloud');
|
||||
const $btnSettings = HeaderSection.#$settingsBtn;
|
||||
if (isElementVisible(HeaderSection.#$buttonsWrapper)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$btnSettings.querySelector('span')!.textContent = getPreferredServerRegion(true) || t('better-xcloud');
|
||||
|
||||
// Show new update status
|
||||
if (!SCRIPT_VERSION.includes('beta') && PREF_LATEST_VERSION && PREF_LATEST_VERSION !== SCRIPT_VERSION) {
|
||||
$settingsBtn.setAttribute('data-update-available', 'true');
|
||||
$btnSettings.setAttribute('data-update-available', 'true');
|
||||
}
|
||||
|
||||
// Add the Settings button to the web page
|
||||
@ -75,6 +79,9 @@ export class HeaderSection {
|
||||
return;
|
||||
}
|
||||
|
||||
HeaderSection.#timeout && clearTimeout(HeaderSection.#timeout);
|
||||
HeaderSection.#timeout = null;
|
||||
|
||||
HeaderSection.#observer && HeaderSection.#observer.disconnect();
|
||||
HeaderSection.#observer = new MutationObserver(mutationList => {
|
||||
HeaderSection.#timeout && clearTimeout(HeaderSection.#timeout);
|
||||
|
@ -128,6 +128,18 @@ export const BxExposed = {
|
||||
return true;
|
||||
}
|
||||
|
||||
const dict = {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
key: 'XF86Back',
|
||||
code: 'XF86Back',
|
||||
keyCode: 4,
|
||||
which: 4,
|
||||
};
|
||||
|
||||
document.body.dispatchEvent(new KeyboardEvent('keydown', dict));
|
||||
document.body.dispatchEvent(new KeyboardEvent('keyup', dict));
|
||||
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
@ -146,5 +146,10 @@ export function escapeHtml(html: string): string {
|
||||
return $span.innerHTML;
|
||||
}
|
||||
|
||||
export function isElementVisible($elm: HTMLElement): boolean {
|
||||
const rect = $elm.getBoundingClientRect();
|
||||
return !!rect.width && !!rect.height;
|
||||
}
|
||||
|
||||
export const CTN = document.createTextNode.bind(document);
|
||||
window.BX_CE = createElement;
|
||||
|
Reference in New Issue
Block a user