From 9609d0ae7bd1161951b8c546c21c914026d2aa3f Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:43:07 +0700 Subject: [PATCH] Fix duplicated CSS strings --- src/index.ts | 7 +++++-- src/modules/loading-screen.ts | 6 ++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 01b4d62..daf2688 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,8 +67,10 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') { // Stop loading window.stop(); - // Show the reloading overlay - const css = compressCss(` + // We need to set it to an empty string first to work around Bun's bug + // https://github.com/oven-sh/bun/issues/12067 + let css = ''; + css += compressCss(` .bx-reload-overlay { position: fixed; top: 0; @@ -115,6 +117,7 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') { }, '🤓 ' + t('how-to-fix')); } + // Show the reloading overlay const $fragment = document.createDocumentFragment(); $fragment.appendChild(CE('style', {}, css)); $fragment.appendChild(CE('div',{ diff --git a/src/modules/loading-screen.ts b/src/modules/loading-screen.ts index 79e6614..e6f5fb7 100644 --- a/src/modules/loading-screen.ts +++ b/src/modules/loading-screen.ts @@ -44,7 +44,7 @@ export class LoadingScreen { static #hideRocket() { let $bgStyle = LoadingScreen.#$bgStyle; - const css = compressCss(` + $bgStyle.textContent! += compressCss(` #game-stream div[class*=RocketAnimation-module__container] > svg { display: none; } @@ -53,7 +53,6 @@ export class LoadingScreen { display: none; } `); - $bgStyle.textContent! += css; } static #setBackground(imageUrl: string) { @@ -63,7 +62,7 @@ export class LoadingScreen { // Limit max width to reduce image size imageUrl = imageUrl + '?w=1920'; - const css = compressCss(` + $bgStyle.textContent! += compressCss(` #game-stream { background-color: transparent !important; background-position: center center !important; @@ -75,7 +74,6 @@ export class LoadingScreen { transition: opacity 0.3s ease-in-out !important; } `) + `#game-stream {background-image: linear-gradient(#00000033, #000000e6), url(${imageUrl}) !important;}`; - $bgStyle.textContent! += css; const bg = new Image(); bg.onload = e => {