feat: add common method injectCSS

* refactor: address ts errors
This commit is contained in:
Hakadao
2023-09-10 14:17:00 +08:00
parent b0bbf57732
commit 3bb7e264bd
4 changed files with 32 additions and 23 deletions

View File

@@ -4,19 +4,12 @@ import App from './views/App.vue'
import { setupApp } from '~/logic/common-setup'
import { i18n } from '~/utils/i18n'
import { SVG_ICONS } from '~/utils/svgIcons'
import { injectCSS } from '~/utils/main'
let app: any
const isFirefox: boolean = /Firefox/i.test(navigator.userAgent)
function injectCSS(css: string): HTMLStyleElement {
const el = document.createElement('style')
el.setAttribute('rel', 'stylesheet')
el.innerText = css
document.documentElement.appendChild(el)
return el
}
const beforeLoadedStyleEl = injectCSS(`
html.dark {
background: hsl(230 12% 6%);
@@ -70,6 +63,8 @@ function injectApp() {
|| /https?:\/\/search.bilibili.com\.*/.test(currentUrl)
// moments
|| /https?:\/\/t.bilibili.com\.*/.test(currentUrl)
// history page
|| /https?:\/\/(www.)?bilibili.com\/account\/history.*/.test(currentUrl)
) {
if (
/https?:\/\/bilibili.com\/?$/.test(currentUrl)