Compare commits

...

14 Commits

Author SHA1 Message Date
422442071e Bump version to 5.1.3 2024-07-09 18:31:18 +07:00
8d1ae0656c Update better-xcloud.user.js 2024-07-09 07:53:46 +07:00
a78de2ca37 Hide Stream settings when the Guide menu is shown (#441) 2024-07-09 07:53:36 +07:00
db1da22c0a Remove SMART_TV_UNIQUE_ID from SMART_TV_GENERIC profile 2024-07-09 07:48:05 +07:00
91ab57fa29 Remove website's version detection 2024-07-09 07:46:42 +07:00
416307e23a Fix "alwaysShowStreamHud" not working on non-TV devices 2024-07-08 20:05:20 +07:00
e7c94f3ece Update better-xcloud.user.js 2024-07-08 18:06:23 +07:00
ea9ad16770 Don't show negative packetLost 2024-07-08 18:02:07 +07:00
9a2e7de68d Update better-xcloud.user.js 2024-07-08 17:55:01 +07:00
962f4dec6d Minor update 2024-07-08 17:45:38 +07:00
10d0dedc0a Add "alwaysShowStreamHud" patch 2024-07-08 17:17:28 +07:00
c6acc251ae Update bun 2024-07-08 08:06:54 +07:00
a06d061409 Update better-xcloud.user.js 2024-07-08 07:32:33 +07:00
6b2412ff27 Disable Onboarding screen 2024-07-08 07:32:16 +07:00
16 changed files with 131 additions and 50 deletions

View File

@ -4,6 +4,7 @@ import { parseArgs } from "node:util";
import { sys } from "typescript"; import { sys } from "typescript";
import txtScriptHeader from "./src/assets/header_script.txt" with { type: "text" }; import txtScriptHeader from "./src/assets/header_script.txt" with { type: "text" };
import txtMetaHeader from "./src/assets/header_meta.txt" with { type: "text" }; import txtMetaHeader from "./src/assets/header_meta.txt" with { type: "text" };
import { assert } from "node:console";
enum BuildTarget { enum BuildTarget {
ALL = 'all', ALL = 'all',
@ -24,6 +25,8 @@ const postProcess = (str: string): string => {
// Add ADDITIONAL CODE block // Add ADDITIONAL CODE block
str = str.replace('var DEFAULT_FLAGS', '\n/* ADDITIONAL CODE */\n\nvar DEFAULT_FLAGS'); str = str.replace('var DEFAULT_FLAGS', '\n/* ADDITIONAL CODE */\n\nvar DEFAULT_FLAGS');
assert(str.includes('/* ADDITIONAL CODE */'));
return str; return str;
} }

BIN
bun.lockb

Binary file not shown.

View File

@ -1,5 +1,5 @@
// ==UserScript== // ==UserScript==
// @name Better xCloud // @name Better xCloud
// @namespace https://github.com/redphx // @namespace https://github.com/redphx
// @version 5.1.2 // @version 5.1.3
// ==/UserScript== // ==/UserScript==

File diff suppressed because one or more lines are too long

View File

@ -6,8 +6,8 @@
"build": "build.ts" "build": "build.ts"
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "^1.1.5", "@types/bun": "^1.1.6",
"@types/node": "^20.14.9", "@types/node": "^20.14.10",
"@types/stylus": "^0.48.42", "@types/stylus": "^0.48.42",
"stylus": "^0.63.0" "stylus": "^0.63.0"
}, },

View File

@ -48,11 +48,17 @@
text-decoration: none; text-decoration: none;
font-weight: bold; font-weight: bold;
display: block; display: block;
color: #5dc21e;
flex: 1; flex: 1;
text-transform: none;
span {
color: #5dc21e !important;
}
&:focus { &:focus {
color: #83f73a; span {
color: #83f73a !important;
}
} }
} }

View File

@ -1,8 +1,8 @@
export enum UserAgentProfile { export enum UserAgentProfile {
WINDOWS_EDGE = 'windows-edge', WINDOWS_EDGE = 'windows-edge',
MACOS_SAFARI = 'macos-safari', MACOS_SAFARI = 'macos-safari',
SMARTTV_GENERIC = 'smarttv-generic', SMART_TV_GENERIC = 'smarttv-generic',
SMARTTV_TIZEN = 'smarttv-tizen', SMART_TV_TIZEN = 'smarttv-tizen',
VR_OCULUS = 'vr-oculus', VR_OCULUS = 'vr-oculus',
DEFAULT = 'default', DEFAULT = 'default',
CUSTOM = 'custom', CUSTOM = 'custom',

View File

@ -738,6 +738,43 @@ true` + text;
str = str.substring(0, index) + 'true ? null :' + str.substring(index); str = str.substring(0, index) + 'true ? null :' + str.substring(index);
return str; return str;
}, },
// Override Storage.getSettings()
overrideStorageGetSettings(str: string) {
const text = '}getSetting(e){';
if (!str.includes(text)) {
return false;
}
const newCode = `
// console.log('setting', this.baseStorageKey, e);
if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
const settings = window.BX_EXPOSED.overrideSettings[this.baseStorageKey];
if (e in settings) {
return settings[e];
}
}
`;
str = str.replace(text, text + newCode);
return str;
},
// game-stream.js 24.16.4
alwaysShowStreamHud(str: string) {
let index = str.indexOf(',{onShowStreamMenu:');
if (index === -1) {
return false;
}
index = str.indexOf('&&(0,', index - 100);
if (index === -1) {
return false;
}
const commaIndex = str.indexOf(',', index - 10);
str = str.substring(0, commaIndex) + ',true' + str.substring(index);
return str;
},
}; };
let PATCH_ORDERS: PatchArray = [ let PATCH_ORDERS: PatchArray = [
@ -759,6 +796,8 @@ let PATCH_ORDERS: PatchArray = [
'enableTvRoutes', 'enableTvRoutes',
'overrideStorageGetSettings',
getPref(PrefKey.UI_LAYOUT) !== 'default' && 'websiteLayout', getPref(PrefKey.UI_LAYOUT) !== 'default' && 'websiteLayout',
getPref(PrefKey.LOCAL_CO_OP_ENABLED) && 'supportLocalCoOp', getPref(PrefKey.LOCAL_CO_OP_ENABLED) && 'supportLocalCoOp',
getPref(PrefKey.GAME_FORTNITE_FORCE_CONSOLE) && 'forceFortniteConsole', getPref(PrefKey.GAME_FORTNITE_FORCE_CONSOLE) && 'forceFortniteConsole',
@ -797,6 +836,8 @@ let PLAYING_PATCH_ORDERS: PatchArray = [
'patchStreamHud', 'patchStreamHud',
'playVibration', 'playVibration',
'alwaysShowStreamHud',
// 'exposeEventTarget', // 'exposeEventTarget',
// Patch volume control for normal stream // Patch volume control for normal stream

View File

@ -240,6 +240,9 @@ export class StreamSettings {
constructor() { constructor() {
this.#setupDialog(); this.#setupDialog();
// Hide dialog when the Guide menu is shown
window.addEventListener(BxEvent.XCLOUD_GUIDE_MENU_SHOWN, e => this.hide());
} }
show(tabId?: string) { show(tabId?: string) {

View File

@ -142,10 +142,10 @@ export class StreamStats {
this.#$fps!.textContent = stat.framesPerSecond || 0; this.#$fps!.textContent = stat.framesPerSecond || 0;
// Packets Lost // Packets Lost
const packetsLost = stat.packetsLost; const packetsLost = Math.max(0, stat.packetsLost); // packetsLost can be negative, but we don't care about that
const packetsReceived = stat.packetsReceived; const packetsReceived = stat.packetsReceived;
const packetsLostPercentage = (packetsLost * 100 / ((packetsLost + packetsReceived) || 1)).toFixed(2); const packetsLostPercentage = (packetsLost * 100 / ((packetsLost + packetsReceived) || 1)).toFixed(2);
this.#$pl!.textContent = packetsLostPercentage === '0.00' ? packetsLost : `${packetsLost} (${packetsLostPercentage}%)`; this.#$pl!.textContent = packetsLostPercentage === '0.00' ? packetsLost.toString() : `${packetsLost} (${packetsLostPercentage}%)`;
// Frames dropped // Frames dropped
const framesDropped = stat.framesDropped; const framesDropped = stat.framesDropped;

View File

@ -132,11 +132,12 @@ export function setupSettingsUi() {
const $wrapper = CE('div', {'class': 'bx-settings-wrapper'}, const $wrapper = CE('div', {'class': 'bx-settings-wrapper'},
CE('div', {'class': 'bx-settings-title-wrapper'}, CE('div', {'class': 'bx-settings-title-wrapper'},
CE('a', { createButton({
'class': 'bx-settings-title', classes: ['bx-settings-title'],
'href': 'https://github.com/redphx/better-xcloud/releases', style: ButtonStyle.FOCUSABLE | ButtonStyle.GHOST,
'target': '_blank', label: 'Better xCloud ' + SCRIPT_VERSION,
}, 'Better xCloud ' + SCRIPT_VERSION), url: 'https://github.com/redphx/better-xcloud/releases',
}),
createButton({ createButton({
icon: BxIcon.QUESTION, icon: BxIcon.QUESTION,
style: ButtonStyle.FOCUSABLE, style: ButtonStyle.FOCUSABLE,
@ -427,13 +428,6 @@ export function setupSettingsUi() {
}, `❤️ ${t('support-better-xcloud')}`); }, `❤️ ${t('support-better-xcloud')}`);
$wrapper.appendChild($donationLink); $wrapper.appendChild($donationLink);
// Show Game Pass app version
try {
const appVersion = (document.querySelector('meta[name=gamepass-app-version]') as HTMLMetaElement).content;
const appDate = new Date((document.querySelector('meta[name=gamepass-app-date]') as HTMLMetaElement).content).toISOString().substring(0, 10);
$wrapper.appendChild(CE('div', {'class': 'bx-settings-app-version'}, `xCloud website version ${appVersion} (${appDate})`));
} catch (e) {}
$container.appendChild($wrapper); $container.appendChild($wrapper);
// Add Settings UI to the web page // Add Settings UI to the web page

View File

@ -36,6 +36,7 @@ type BxStates = {
}; };
userAgent: { userAgent: {
isTv: boolean;
capabilities: { capabilities: {
touch: boolean; touch: boolean;
}; };

View File

@ -109,4 +109,10 @@ export const BxExposed = {
handleControllerShortcut: ControllerShortcut.handle, handleControllerShortcut: ControllerShortcut.handle,
resetControllerShortcut: ControllerShortcut.reset, resetControllerShortcut: ControllerShortcut.reset,
overrideSettings: {
'Tv_settings': {
hasCompletedOnboarding: true,
},
},
}; };

View File

@ -25,6 +25,7 @@ export const STATES: BxStates = {
}, },
userAgent: { userAgent: {
isTv: isTv,
capabilities: { capabilities: {
touch: userAgentHasTouchSupport, touch: userAgentHasTouchSupport,
} }

View File

@ -589,8 +589,8 @@ export class Preferences {
[UserAgentProfile.DEFAULT]: t('default'), [UserAgentProfile.DEFAULT]: t('default'),
[UserAgentProfile.WINDOWS_EDGE]: 'Edge + Windows', [UserAgentProfile.WINDOWS_EDGE]: 'Edge + Windows',
[UserAgentProfile.MACOS_SAFARI]: 'Safari + macOS', [UserAgentProfile.MACOS_SAFARI]: 'Safari + macOS',
[UserAgentProfile.SMARTTV_GENERIC]: 'Smart TV', [UserAgentProfile.SMART_TV_GENERIC]: 'Smart TV',
[UserAgentProfile.SMARTTV_TIZEN]: 'Samsung Smart TV', [UserAgentProfile.SMART_TV_TIZEN]: 'Samsung Smart TV',
[UserAgentProfile.VR_OCULUS]: 'Meta Quest VR', [UserAgentProfile.VR_OCULUS]: 'Meta Quest VR',
[UserAgentProfile.CUSTOM]: t('custom'), [UserAgentProfile.CUSTOM]: t('custom'),
}, },

View File

@ -29,8 +29,8 @@ export class UserAgent {
static #USER_AGENTS: PartialRecord<UserAgentProfile, string> = { static #USER_AGENTS: PartialRecord<UserAgentProfile, string> = {
[UserAgentProfile.WINDOWS_EDGE]: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${CHROMIUM_VERSION} Safari/537.36 Edg/${CHROMIUM_VERSION}`, [UserAgentProfile.WINDOWS_EDGE]: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${CHROMIUM_VERSION} Safari/537.36 Edg/${CHROMIUM_VERSION}`,
[UserAgentProfile.MACOS_SAFARI]: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5.2 Safari/605.1.1', [UserAgentProfile.MACOS_SAFARI]: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5.2 Safari/605.1.1',
[UserAgentProfile.SMARTTV_GENERIC]: `${window.navigator.userAgent} SmartTV ${SMART_TV_UNIQUE_ID}`, [UserAgentProfile.SMART_TV_GENERIC]: `${window.navigator.userAgent} SmartTV`,
[UserAgentProfile.SMARTTV_TIZEN]: `Mozilla/5.0 (SMART-TV; LINUX; Tizen 7.0) AppleWebKit/537.36 (KHTML, like Gecko) ${CHROMIUM_VERSION}/7.0 TV Safari/537.36 ${SMART_TV_UNIQUE_ID}`, [UserAgentProfile.SMART_TV_TIZEN]: `Mozilla/5.0 (SMART-TV; LINUX; Tizen 7.0) AppleWebKit/537.36 (KHTML, like Gecko) ${CHROMIUM_VERSION}/7.0 TV Safari/537.36 ${SMART_TV_UNIQUE_ID}`,
[UserAgentProfile.VR_OCULUS]: window.navigator.userAgent + ' OculusBrowser VR', [UserAgentProfile.VR_OCULUS]: window.navigator.userAgent + ' OculusBrowser VR',
} }