Improve search box (#1431)

This commit is contained in:
the1812 2021-01-24 21:15:09 +08:00
parent 07543c3199
commit a5eebec62e
4 changed files with 10 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,11 @@ const loadSettings = () => {
addSettingsListener('customNavbarBlurOpacity', value => {
document.documentElement.style.setProperty('--navbar-blur-opacity', value)
})
if (!document.URL.startsWith('https://space.bilibili.com')) {
const fixedNotSupported = [
// 'https://search.bilibili.com/all',
'https://space.bilibili.com',
]
if (!fixedNotSupported.some(url => document.URL.startsWith(url))) {
addSettingsListener('customNavbarGlobalFixed', value => {
document.body.classList.toggle('fixed-navbar', value)
}, true)

View File

@ -141,6 +141,9 @@ export class SearchBox extends NavbarComponent {
const form = await SpinQuery.select('#custom-navbar-search') as HTMLFormElement
const keywordInput = form.querySelector("input[name='keyword']") as HTMLInputElement
migrateOldHistory()
if (document.URL.startsWith('https://search.bilibili.com/all')) {
keywordInput.value = window.location.search.match(/keyword=([^&]+)/)?.[1] || ''
}
form.addEventListener('submit', e => {
if (keywordInput.value === '') {
if (!settings.hideTopSearch) {