diff --git a/src/background/index.ts b/src/background/index.ts index 34ef7780..5e938e3d 100644 --- a/src/background/index.ts +++ b/src/background/index.ts @@ -1,5 +1,6 @@ import type { Tabs } from 'webextension-polyfill' import browser from 'webextension-polyfill' + // import { onMessage, sendMessage } from 'webext-bridge' import { resetCss } from './resetWebsiteStyle' import { setupAllMsgLstnrs } from './messageListeners' @@ -57,15 +58,9 @@ browser.tabs.onUpdated.addListener((tabId: number, changInfo: Tabs.OnUpdatedChan || /https?:\/\/www.bilibili.com\/?$/.test(`${tab.url}`) || /https?:\/\/bilibili.com\/\?spm_id_from=.*/.test(`${tab.url}`) || /https?:\/\/www.bilibili.com\/\?spm_id_from=(.)*/.test(`${tab.url}`) + || true // || /https?:\/\/(www.)?bilibili.com\/video\/.*/.test(`${tab.url}`) ) { - browser.scripting.insertCSS({ - css: resetCss, - target: { - tabId, - }, - }) - if (changInfo.status === 'loading') { // browser.scripting.insertCSS({ // css: ` @@ -81,6 +76,13 @@ browser.tabs.onUpdated.addListener((tabId: number, changInfo: Tabs.OnUpdatedChan // }, // }) + browser.scripting.insertCSS({ + css: resetCss, + target: { + tabId, + }, + }) + // If it not a macOS, we will inject CSS to design the scrollbar if (!navigator.userAgent.includes('Mac OS X')) { browser.scripting.insertCSS({ diff --git a/src/background/resetWebsiteStyle.ts b/src/background/resetWebsiteStyle.ts index 9e96629c..26894e0e 100644 --- a/src/background/resetWebsiteStyle.ts +++ b/src/background/resetWebsiteStyle.ts @@ -3,66 +3,41 @@ export const resetCss = ` * this stylesheet is used to reset the styles of the bilibili default style */ -:root { - --bew-bg: hsl(220, 14%, 96%); +// :root { +// --bew-bg: hsl(220, 14%, 96%); +// } - // --band_blue: var(--bew-theme-color); - // --text1: var(--bew-text-1); - // --text2: var(--bew-text-2); - // --text3: var(--bew-text-3); - // --bg1: var(--bew-content-1); - // --bg2: var(--bew-content-1); - // --bg3: var(--bew-content-1); - // --line-light: var(--bew-fill-2); - // --line_regular: var(--bew-fill-3); - // --line_bold: var(--bew-fill-4); -} - -:root.dark { - --bew-bg: hsl(230 12% 6%); -} +// :root.dark { +// --bew-bg: hsl(230 12% 6%); +// } html, body { font-size: 14px !important; min-width: unset !important; + filter: none !important; } -html, body { - background-color: var(--bew-bg); -} -a, -a:hover { - color: unset; -} +// html, body { +// background-color: var(--bew-bg); +// } -/* -// button { -// border: unset; -// background: unset; +// /* hide the original home page */ +// .login-tip { +// display: none; +// } -// &:focus, -// &:active { -// background: currentColor; -// } -// }*/ - -/* hide the original home page */ -.login-tip { - display: none; -} - -body > #i_cecream, -#i_cecream *, -#app, -.international-footer { - position: absolute; - top: 200vh; - visibility: hidden !important; - width: 0; - height: 0; - overflow: hidden !important; - pointer-events: none !important; - display: none; -} +// body > #i_cecream, +// #i_cecream *, +// /* #app, */ +// .international-footer { +// position: absolute; +// top: 200vh; +// visibility: hidden !important; +// width: 0; +// height: 0; +// overflow: hidden !important; +// pointer-events: none !important; +// display: none; +// } ` diff --git a/src/components/Button.vue b/src/components/Button.vue index fea14801..0d4769b7 100644 --- a/src/components/Button.vue +++ b/src/components/Button.vue @@ -14,6 +14,7 @@ interface Props { color?: string textColor?: string strong?: boolean + round?: boolean } // const props = withDefaults(defineProps(), {}) @@ -37,7 +38,7 @@ function handleClick(evt: MouseEvent) { ${strong ? 'b-button--strong' : ''} ${color || textColor ? 'b-button--custom-color' : ''} `" - :style="{ backgroundColor: color, color: textColor }" + :style="{ 'backgroundColor': color, 'color': textColor, '--b-radius': round ? '50px' : '' }" @click="handleClick" > @@ -59,7 +60,7 @@ function handleClick(evt: MouseEvent) { --at-apply: bg-$b-color hover:bg-$b-color-hover rounded-$b-radius p-$b-padding transform-gpu active:scale-95 duration-300 flex items-center gap-2 text-size-$b-font-size - text-$b-text-color; + text-$b-text-color lh-1.5em; & svg { --at-apply: text-size-$b-icon-size diff --git a/src/components/SearchBar/SearchBar.vue b/src/components/SearchBar/SearchBar.vue index 5f0367dc..6a38ebad 100644 --- a/src/components/SearchBar/SearchBar.vue +++ b/src/components/SearchBar/SearchBar.vue @@ -160,6 +160,7 @@ function handleKeyDown() { @keyup.enter="navigateToSearchResultPage(keyword)" @keyup.up="handleKeyUp" @keyup.down="handleKeyDown" + @keydown.stop="() => {}" > @@ -205,7 +206,7 @@ function handleKeyDown() { pointer-events-auto cursor-pointer text="base $bew-text-2" - leading-0 + leading-0 p-0 @click.stop="handleDelete(item.value)" > diff --git a/src/components/Slider.vue b/src/components/Slider.vue index cc38fb19..2dbad6fa 100644 --- a/src/components/Slider.vue +++ b/src/components/Slider.vue @@ -59,20 +59,20 @@ label { input[type="range"] { &::-webkit-slider-thumb { --at-apply: appearance-none w-$b-thumb-height h-$b-thumb-height bg-white rounded-$b-thumb-height - border-2 border-$bew-border-color cursor-pointer; + ring-$bew-border-color ring-2 cursor-pointer duration-300; } &::-webkit-slider-thumb:hover { - --at-apply: border-$bew-theme-color; + --at-apply: ring-$bew-theme-color; } &::-moz-range-thumb { --at-apply: appearance-none w-$b-thumb-height h-$b-thumb-height bg-white rounded-$b-thumb-height - border-2 border-$bew-border-color cursor-pointer; + ring-$bew-border-color ring-2 cursor-pointer duration-300; } &::-moz-range-thumb:hover { - --at-apply: border-$bew-theme-color; + --at-apply: ring-$bew-theme-color; } } diff --git a/src/components/Topbar/Topbar.vue b/src/components/Topbar/Topbar.vue index 74a31129..f37e1767 100644 --- a/src/components/Topbar/Topbar.vue +++ b/src/components/Topbar/Topbar.vue @@ -200,7 +200,7 @@ function getNewMomentsCount() { opacity="100" pointer-events-none z--1 - :style="{ background: settings.wallpaper ? 'linear-gradient(rgba(0,0,0,.8), transparent)' : `linear-gradient(var(--bew-bg), transparent)` }" + :style="{ background: settings.wallpaper ? 'linear-gradient(rgba(0,0,0,4), transparent)' : `linear-gradient(var(--bew-bg), transparent)` }" /> @@ -209,7 +209,9 @@ function getNewMomentsCount() { @mouseenter.self="showLogoMenuDropdown()" @mouseleave.self="closeLogoMenuDropdown()" > - diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue index 2e27484a..47192c8a 100644 --- a/src/contentScripts/views/App.vue +++ b/src/contentScripts/views/App.vue @@ -11,14 +11,15 @@ import History from './History/History.vue' import WatchLater from './WatchLater/WatchLater.vue' import Favorites from './Favorites/Favorites.vue' import Video from './Video/Video.vue' -import { accessKey, activatedPage, settings } from '~/logic' +import { accessKey, settings } from '~/logic' import '~/styles/index.ts' import { AppPage, LanguageType } from '~/enums/appEnums' import { getUserID, hexToRGBA, smoothScrollToTop } from '~/utils/main' import emitter from '~/utils/mitt' +const activatedPage = ref(AppPage.Home) const { locale } = useI18n() -const [showSettings, toggle] = useToggle(false) +const [showSettings, toggleSettings] = useToggle(false) const isDark = useDark({ onChanged: (isDark: boolean) => { if (isDark) { @@ -101,15 +102,6 @@ watch(() => accessKey.value, () => { accessKey.value = '' }) -watch(() => settings.value.wallpaper, () => { - setAppWallpaper() -}) - -watch(() => settings.value.searchPageWallpaper, () => { - if (activatedPage.value === AppPage.Search) - setAppWallpaper() -}) - watch(() => settings.value.wallpaperMaskOpacity, () => { setAppWallpaperMaskingOpacity() }) @@ -121,10 +113,8 @@ watch(() => settings.value.searchPageWallpaperMaskOpacity, () => { watch(() => activatedPage.value, (newValue, oldValue) => { // If u have set the `individuallySetSearchPageWallpaper`, reapply the wallpaper when the new page is search page // or when switching from a search page to another page, since search page has its own wallpaper. - if (settings.value.individuallySetSearchPageWallpaper && (newValue === AppPage.Search || oldValue === AppPage.Search)) { - setAppWallpaper() + if (settings.value.individuallySetSearchPageWallpaper && (newValue === AppPage.Search || oldValue === AppPage.Search)) setAppWallpaperMaskingOpacity() - } }) onMounted(() => { @@ -153,14 +143,14 @@ onMounted(() => { } if (!isBilibiliHomePage.value) { - const originalTopBar: HTMLElement = document.querySelector('#biliMainHeader') as HTMLElement - originalTopBar!.style.visibility = 'hidden' + const originalTopBar: HTMLElement = document.querySelector('#biliMainHeader, #bili-header-container') as HTMLElement + if (originalTopBar) + originalTopBar.style.visibility = 'hidden' } setAppAppearance() setAppLanguage() setAppThemeColor() - setAppWallpaper() setAppWallpaperMaskingOpacity() }) @@ -210,9 +200,9 @@ function setAppAppearance() { else mainAppRef.value?.classList.remove('dark') - // Override Bilibili Evolved background color - document.body.style.setProperty('background-color', 'unset', 'important') - document.documentElement.style.setProperty('background-color', 'var(--bew-bg)', 'important') + // // Override Bilibili Evolved background color + // document.body.style.setProperty('background-color', 'unset', 'important') + // document.documentElement.style.setProperty('background-color', 'var(--bew-bg)', 'important') } function setAppThemeColor() { @@ -222,19 +212,10 @@ function setAppThemeColor() { for (let i = 0; i < 9; i++) bewlyElement.style.setProperty(`--bew-theme-color-${i + 1}0`, hexToRGBA(settings.value.themeColor, i * 0.1 + 0.1)) } -} -function setAppWallpaper() { - nextTick(() => { - if (settings.value.individuallySetSearchPageWallpaper && activatedPage.value === AppPage.Search) - document.documentElement.style.backgroundImage = `url(${settings.value.searchPageWallpaper})` - else - document.documentElement.style.backgroundImage = `url(${settings.value.wallpaper})` - - document.documentElement.style.backgroundSize = 'cover' - document.documentElement.style.backgroundPosition = 'center' - document.documentElement.style.transition = 'backgroundImage .5s ease-in-out' - }) + document.body.style.setProperty('--bew-theme-color', settings.value.themeColor) + for (let i = 0; i < 9; i++) + document.body.style.setProperty(`--bew-theme-color-${i + 1}0`, hexToRGBA(settings.value.themeColor, i * 0.1 + 0.1)) } function setAppWallpaperMaskingOpacity() { @@ -257,23 +238,47 @@ function handleBackToTop() {