mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
feat: 隐藏直播间热搜
This commit is contained in:
parent
4e8221f089
commit
1616061f65
@ -1,9 +1,8 @@
|
||||
.search-panel {
|
||||
.search-panel, .search-pannel {
|
||||
|
||||
> .trending {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
&:not(:has(.history)) {
|
||||
padding: 0 !important;
|
||||
border: none !important;
|
||||
|
||||
@ -9,6 +9,26 @@ const resetPlaceholder = (input: HTMLInputElement) => {
|
||||
input.title = DEFAULT_PLACEHOLDER
|
||||
}
|
||||
|
||||
const isInLiveRoomPage = () => {
|
||||
return window.location.host === 'live.bilibili.com'
|
||||
}
|
||||
|
||||
const getSearchInputClassName = () => {
|
||||
return isInLiveRoomPage() ? 'input.nav-search-content' : 'input.nav-search-input'
|
||||
}
|
||||
|
||||
const isSearchInput = (target: any) => {
|
||||
if (!(target instanceof HTMLInputElement)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const isSearch = ['nav-search-content', 'nav-search-input'].some(n =>
|
||||
target.classList.contains(n),
|
||||
)
|
||||
|
||||
return target.placeholder !== DEFAULT_PLACEHOLDER && isSearch
|
||||
}
|
||||
|
||||
export const component = defineComponentMetadata({
|
||||
name: 'hideTrendingSearch',
|
||||
displayName: '隐藏热搜',
|
||||
@ -20,7 +40,8 @@ export const component = defineComponentMetadata({
|
||||
},
|
||||
],
|
||||
entry: async () => {
|
||||
const input: HTMLInputElement = await select('input.nav-search-input', {
|
||||
const clsName = getSearchInputClassName()
|
||||
const input: HTMLInputElement = await select(clsName, {
|
||||
queryInterval: 500,
|
||||
})
|
||||
|
||||
@ -32,12 +53,8 @@ export const component = defineComponentMetadata({
|
||||
// Fallback to observer
|
||||
allMutations(records => {
|
||||
records.forEach(record => {
|
||||
if (
|
||||
record.target instanceof HTMLInputElement &&
|
||||
record.target.classList.contains('nav-search-input') &&
|
||||
record.target.placeholder !== DEFAULT_PLACEHOLDER
|
||||
) {
|
||||
resetPlaceholder(record.target)
|
||||
if (isSearchInput(record.target)) {
|
||||
resetPlaceholder(record.target as HTMLInputElement)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user