Optimize built scripts

This commit is contained in:
redphx 2024-10-10 21:43:42 +07:00
parent 728abced45
commit 6fa1f73702
3 changed files with 30 additions and 25 deletions

View File

@ -55,7 +55,7 @@ const postProcess = (str: string): string => {
// Minify SVG import code
const svgMap = {}
str = str.replaceAll(/var ([\w_]+) = ("<svg.*?");\n\n/g, function(match, p1, p2) {
str = str.replaceAll(/var ([\w_]+) = ("<svg.*?");\n\n/g, (match, p1, p2) => {
// 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'));

View File

@ -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

View File

@ -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