From 3f8030a9c52ccb5fb24bb88aa9846d33093eae52 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sun, 26 Nov 2023 23:25:38 +0900 Subject: [PATCH] fix: inject multiple stylesheet --- src/loader/renderer.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/loader/renderer.ts b/src/loader/renderer.ts index 01822b08..c17d5af9 100644 --- a/src/loader/renderer.ts +++ b/src/loader/renderer.ts @@ -56,13 +56,16 @@ export const forceLoadRendererPlugin = (id: string) => { if (hasEvaled || plugin?.stylesheets) { loadedPluginMap[id] = plugin; - if (plugin?.stylesheets) - document.head.appendChild( - Object.assign(document.createElement('style'), { - id: `plugin-${id}`, - innerHTML: plugin?.stylesheets ?? '', - }), - ); + if (plugin?.stylesheets) { + const styleSheetList = plugin.stylesheets.map((style) => { + const styleSheet = new CSSStyleSheet(); + styleSheet.replaceSync(style); + + return styleSheet; + }); + + document.adoptedStyleSheets = [...document.adoptedStyleSheets, ...styleSheetList]; + } if (!hasEvaled) console.log('[YTMusic]', `"${id}" plugin is loaded`); } else {