diff --git a/hwe/ts/common_deprecated.ts b/hwe/ts/common_deprecated.ts index 90131575..3aa4e772 100644 --- a/hwe/ts/common_deprecated.ts +++ b/hwe/ts/common_deprecated.ts @@ -11,21 +11,17 @@ import { nl2br } from "@util/nl2br"; import jQuery from "jquery"; import "@scss/common_legacy.scss"; +import { insertCustomCSS } from "./util/customCSS"; +import { htmlReady } from "./util/htmlReady"; exportWindow(jQuery, '$'); exportWindow(jQuery, 'jQuery'); -jQuery(function ($) { +htmlReady(function(){ initTooltip(); activateFlip(); - - const customCSS = localStorage.getItem('sam_customCSS'); - if (customCSS) { - const $style = $(''); - $style.text(customCSS); - $style.appendTo($('head')); - } -}); + insertCustomCSS(); +}) /** * {0}, {1}, {2}형태로 포맷해주는 함수 diff --git a/hwe/ts/legacy/main.ts b/hwe/ts/legacy/main.ts index c681ac97..d72a9aae 100644 --- a/hwe/ts/legacy/main.ts +++ b/hwe/ts/legacy/main.ts @@ -6,6 +6,7 @@ import { initTooltip } from './initTooltip'; import { exportWindow } from '@/util/exportWindow'; import { reloadWorldMap } from '@/map'; import { refreshMsg } from '@/msg'; +import { insertCustomCSS } from '@/util/customCSS'; exportWindow(jQuery, '$'); @@ -50,12 +51,7 @@ htmlReady(() => { void refreshMsg(); }, 5000); - const customCSS = localStorage.getItem('sam_customCSS'); - if (customCSS) { - const styleEl = document.createElement('style'); - styleEl.innerHTML = customCSS; - document.head.appendChild(styleEl); - } + insertCustomCSS(); }); (() => { diff --git a/hwe/ts/util/customCSS.ts b/hwe/ts/util/customCSS.ts new file mode 100644 index 00000000..29e55eff --- /dev/null +++ b/hwe/ts/util/customCSS.ts @@ -0,0 +1,9 @@ +export function insertCustomCSS(key = 'sam_customCSS'){ + const customCSS = localStorage.getItem(key); + if (customCSS) { + const css = document.createElement('style'); + css.innerHTML = customCSS; + console.log(css); + document.getElementsByTagName('head')[0].appendChild(css); + } +}