Fix duplicated CSS strings

This commit is contained in:
redphx 2024-09-25 19:43:07 +07:00
parent 506fd71433
commit 9609d0ae7b
2 changed files with 7 additions and 6 deletions

View File

@ -67,8 +67,10 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') {
// Stop loading // Stop loading
window.stop(); window.stop();
// Show the reloading overlay // We need to set it to an empty string first to work around Bun's bug
const css = compressCss(` // https://github.com/oven-sh/bun/issues/12067
let css = '';
css += compressCss(`
.bx-reload-overlay { .bx-reload-overlay {
position: fixed; position: fixed;
top: 0; top: 0;
@ -115,6 +117,7 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') {
}, '🤓 ' + t('how-to-fix')); }, '🤓 ' + t('how-to-fix'));
} }
// Show the reloading overlay
const $fragment = document.createDocumentFragment(); const $fragment = document.createDocumentFragment();
$fragment.appendChild(CE('style', {}, css)); $fragment.appendChild(CE('style', {}, css));
$fragment.appendChild(CE('div',{ $fragment.appendChild(CE('div',{

View File

@ -44,7 +44,7 @@ export class LoadingScreen {
static #hideRocket() { static #hideRocket() {
let $bgStyle = LoadingScreen.#$bgStyle; let $bgStyle = LoadingScreen.#$bgStyle;
const css = compressCss(` $bgStyle.textContent! += compressCss(`
#game-stream div[class*=RocketAnimation-module__container] > svg { #game-stream div[class*=RocketAnimation-module__container] > svg {
display: none; display: none;
} }
@ -53,7 +53,6 @@ export class LoadingScreen {
display: none; display: none;
} }
`); `);
$bgStyle.textContent! += css;
} }
static #setBackground(imageUrl: string) { static #setBackground(imageUrl: string) {
@ -63,7 +62,7 @@ export class LoadingScreen {
// Limit max width to reduce image size // Limit max width to reduce image size
imageUrl = imageUrl + '?w=1920'; imageUrl = imageUrl + '?w=1920';
const css = compressCss(` $bgStyle.textContent! += compressCss(`
#game-stream { #game-stream {
background-color: transparent !important; background-color: transparent !important;
background-position: center center !important; background-position: center center !important;
@ -75,7 +74,6 @@ export class LoadingScreen {
transition: opacity 0.3s ease-in-out !important; transition: opacity 0.3s ease-in-out !important;
} }
`) + `#game-stream {background-image: linear-gradient(#00000033, #000000e6), url(${imageUrl}) !important;}`; `) + `#game-stream {background-image: linear-gradient(#00000033, #000000e6), url(${imageUrl}) !important;}`;
$bgStyle.textContent! += css;
const bg = new Image(); const bg = new Image();
bg.onload = e => { bg.onload = e => {