From 6fa1f737027f875bad11da5989092ab271bf1fde Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Thu, 10 Oct 2024 21:43:42 +0700 Subject: [PATCH] Optimize built scripts --- build.ts | 7 ++++++- dist/better-xcloud.lite.user.js | 24 ++++++++++++------------ dist/better-xcloud.user.js | 24 ++++++++++++------------ 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/build.ts b/build.ts index 0a67137..95fab32 100644 --- a/build.ts +++ b/build.ts @@ -55,7 +55,7 @@ const postProcess = (str: string): string => { // Minify SVG import code const svgMap = {} - str = str.replaceAll(/var ([\w_]+) = (" { // Remove new lines in SVG p2 = p2.replaceAll(/\\n*\s*/g, ''); @@ -82,6 +82,11 @@ const postProcess = (str: string): string => { // Remove comment line str = str.replaceAll(/\\n\/\/.*?(?=\\n)/g, ''); + // Replace ${"time".toUpperCase()} with "TIME" + str = str.replaceAll(/\$\{"([^"]+)"\.toUpperCase\(\)\}/g, (match, p1) => { + return p1.toUpperCase(); + }); + assert(str.includes('/* ADDITIONAL CODE */')); assert(str.includes('window.BX_EXPOSED = BxExposed')); assert(str.includes('window.BxEvent = BxEvent')); diff --git a/dist/better-xcloud.lite.user.js b/dist/better-xcloud.lite.user.js index 4b5801a..8fc7df5 100644 --- a/dist/better-xcloud.lite.user.js +++ b/dist/better-xcloud.lite.user.js @@ -1665,18 +1665,18 @@ class GlobalSettingsStorage extends BaseSettingsStore { label: t("stats"), default: ["ping", "fps", "btr", "dt", "pl", "fl"], multipleOptions: { - time: `${"time".toUpperCase()}: ${t("clock")}`, - play: `${"play".toUpperCase()}: ${t("playtime")}`, - batt: `${"batt".toUpperCase()}: ${t("battery")}`, - ping: `${"ping".toUpperCase()}: ${t("stat-ping")}`, - jit: `${"jit".toUpperCase()}: ${t("jitter")}`, - fps: `${"fps".toUpperCase()}: ${t("stat-fps")}`, - btr: `${"btr".toUpperCase()}: ${t("stat-bitrate")}`, - dt: `${"dt".toUpperCase()}: ${t("stat-decode-time")}`, - pl: `${"pl".toUpperCase()}: ${t("stat-packets-lost")}`, - fl: `${"fl".toUpperCase()}: ${t("stat-frames-lost")}`, - dl: `${"dl".toUpperCase()}: ${t("downloaded")}`, - ul: `${"ul".toUpperCase()}: ${t("uploaded")}` + time: `TIME: ${t("clock")}`, + play: `PLAY: ${t("playtime")}`, + batt: `BATT: ${t("battery")}`, + ping: `PING: ${t("stat-ping")}`, + jit: `JIT: ${t("jitter")}`, + fps: `FPS: ${t("stat-fps")}`, + btr: `BTR: ${t("stat-bitrate")}`, + dt: `DT: ${t("stat-decode-time")}`, + pl: `PL: ${t("stat-packets-lost")}`, + fl: `FL: ${t("stat-frames-lost")}`, + dl: `DL: ${t("downloaded")}`, + ul: `UL: ${t("uploaded")}` }, params: { size: 6 diff --git a/dist/better-xcloud.user.js b/dist/better-xcloud.user.js index ae7c1dd..bbdf0d5 100644 --- a/dist/better-xcloud.user.js +++ b/dist/better-xcloud.user.js @@ -1692,18 +1692,18 @@ class GlobalSettingsStorage extends BaseSettingsStore { label: t("stats"), default: ["ping", "fps", "btr", "dt", "pl", "fl"], multipleOptions: { - time: `${"time".toUpperCase()}: ${t("clock")}`, - play: `${"play".toUpperCase()}: ${t("playtime")}`, - batt: `${"batt".toUpperCase()}: ${t("battery")}`, - ping: `${"ping".toUpperCase()}: ${t("stat-ping")}`, - jit: `${"jit".toUpperCase()}: ${t("jitter")}`, - fps: `${"fps".toUpperCase()}: ${t("stat-fps")}`, - btr: `${"btr".toUpperCase()}: ${t("stat-bitrate")}`, - dt: `${"dt".toUpperCase()}: ${t("stat-decode-time")}`, - pl: `${"pl".toUpperCase()}: ${t("stat-packets-lost")}`, - fl: `${"fl".toUpperCase()}: ${t("stat-frames-lost")}`, - dl: `${"dl".toUpperCase()}: ${t("downloaded")}`, - ul: `${"ul".toUpperCase()}: ${t("uploaded")}` + time: `TIME: ${t("clock")}`, + play: `PLAY: ${t("playtime")}`, + batt: `BATT: ${t("battery")}`, + ping: `PING: ${t("stat-ping")}`, + jit: `JIT: ${t("jitter")}`, + fps: `FPS: ${t("stat-fps")}`, + btr: `BTR: ${t("stat-bitrate")}`, + dt: `DT: ${t("stat-decode-time")}`, + pl: `PL: ${t("stat-packets-lost")}`, + fl: `FL: ${t("stat-frames-lost")}`, + dl: `DL: ${t("downloaded")}`, + ul: `UL: ${t("uploaded")}` }, params: { size: 6