mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Update home hidden for new homepage (#2209)
This commit is contained in:
parent
4ec2fe670d
commit
5f3c2b6ff3
2
min/dark.min.css
vendored
2
min/dark.min.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
min/home-hidden.min.js
vendored
2
min/home-hidden.min.js
vendored
@ -1 +1 @@
|
||||
(()=>(e,n)=>{const i=()=>{if(document.URL==="https://www.bilibili.com/"){return!e.simplifyHome}return document.URL.includes("https://www.bilibili.com/")};const t=[{name:"categories",displayName:"分区栏",style:`\n .bili-header-m>.bili-wrapper {\n visibility: hidden !important;\n height: 18px !important;\n }\n .primary-menu-itnl {\n visibility: hidden !important;\n height: 24px !important;\n padding: 0 !important;\n }\n`},{name:"trends",displayName:"活动/热门视频",style:`\n .first-screen #reportFirst1 { display: none !important; }\n .first-screen .space-between {\n margin-bottom: 0 !important;\n }\n .rcmd-box-wrap { display: none !important; }\n`},{name:"online",displayName:"在线列表",style:`\n .first-screen #reportFirst2 { display: none !important; }\n`},{name:"ext-box",displayName:"电竞赛事",style:`\n .first-screen #reportFirst3 { display: none !important; } `},{name:"special",displayName:"特别推荐",style:`\n #bili_report_spe_rec { display: none !important; }\n`},{name:"contact",displayName:"联系方式",style:`\n .international-footer { display: none !important; }\n`},{name:"elevator",displayName:"右侧分区导航",style:`\n .storey-box .elevator { display: none !important; }\n`}];const s=i=>{if(!e.homeHiddenItems.includes(i.name)){if(i.style){var t;(t=dq(`#home-hidden-style-${i.name}`))===null||t===void 0?void 0:t.remove()}else{document.body.classList.remove(`home-hidden-${i.name}`)}}else{if(i.style){n.applyImportantStyleFromText(i.style,`home-hidden-style-${i.name}`)}else{document.body.classList.add(`home-hidden-${i.name}`)}}};(async()=>{if(!i()){return}const e=(await SpinQuery.condition((()=>dqa(".proxy-box > div")),(e=>e.length>0||document.URL!=="https://www.bilibili.com/"))).map((e=>{var n,i,t;return{name:e.id.replace(/^bili_/,""),displayName:(n=(i=e.querySelector("header .name"))===null||i===void 0?void 0:(t=i.textContent)===null||t===void 0?void 0:t.trim())!==null&&n!==void 0?n:"未知分区"}}));t.push(...e);t.forEach(s);const o=e.map((({name:e})=>`\nbody.home-hidden-${e} .storey-box .proxy-box #bili_${e} {\n display: none !important;\n}\n`.trim())).join("\n");const d=n.import("homeHiddenStyle");n.applyImportantStyleFromText(o+d,"home-hidden-style")})();return{widget:{condition:i,content:`\n<div class="gui-settings-flat-button" style="position: relative" id="home-hidden">\n<i class="mdi mdi-24px mdi-settings"></i>\n<span>首页过滤</span>\n<div class="home-hidden-settings popup">\n<div v-for="item in items" @click="toggle(item)" :key="item.name" class="home-hidden-settings-item" :class="{ 'home-hidden': hiddenItems.includes(item.name) }">\n<i class="mdi mdi-18px mdi-eye"></i>\n<i class="mdi mdi-18px mdi-eye-off"></i>\n {{ item.displayName }}\n</div>\n</div>\n</div>\n`,success:async()=>{const n=dq("#home-hidden");new Vue({el:dq(n,".popup"),data(){return{items:t,hiddenItems:[...e.homeHiddenItems]}},watch:{hiddenItems(n){e.homeHiddenItems=[...n]}},mounted(){const e=this.$el;n.addEventListener("click",(n=>{if(n.target===e||e.contains(n.target)){return}e.classList.toggle("opened")}))},methods:{async toggle(e){const n=this.hiddenItems;const i=n.indexOf(e.name);if(i!==-1){n.splice(i,1)}else{n.push(e.name)}await this.$nextTick();s(e)}}})}}}})();
|
||||
(()=>(e,n)=>{const i=()=>{if(document.URL==="https://www.bilibili.com/"){return!e.simplifyHome}return document.URL.includes("https://www.bilibili.com/")};const t=[{name:"categories",displayName:"分区栏",style:`\n .bili-header-m>.bili-wrapper {\n visibility: hidden !important;\n height: 18px !important;\n }\n .primary-menu-itnl {\n visibility: hidden !important;\n height: 24px !important;\n padding: 0 !important;\n }\n .bili-header__channel {\n height: 12px !important;\n }\n .bili-header__channel > * {\n display: none !important;\n }\n`},{name:"trends",displayName:"活动/热门视频",style:`\n .first-screen #reportFirst1 { display: none !important; }\n .first-screen .space-between {\n margin-bottom: 0 !important;\n }\n .bili-layout .bili-grid:first-child,\n .rcmd-box-wrap {\n display: none !important;\n }\n`},{name:"online",displayName:"在线列表(旧版)",style:`\n .first-screen #reportFirst2 { display: none !important; }\n`},{name:"ext-box",displayName:"赛事(旧版)",style:`\n .first-screen #reportFirst3 { display: none !important; } `},{name:"special",displayName:"特别推荐(旧版)",style:`\n #bili_report_spe_rec { display: none !important; }\n`},{name:"contact",displayName:"联系方式",style:`\n .bili-footer .b-footer-wrap,\n .international-footer {\n display: none !important;\n }\n`},{name:"elevator",displayName:"右侧分区导航(旧版)",style:`\n .storey-box .elevator { display: none !important; }\n`}];const o=i=>{if(!e.homeHiddenItems.includes(i.name)){if(i.style){var t;(t=dq(`#home-hidden-style-${i.name}`))===null||t===void 0?void 0:t.remove()}else{document.body.classList.remove(`home-hidden-${i.name}`)}}else{if(i.style){n.applyImportantStyleFromText(i.style,`home-hidden-style-${i.name}`)}else{document.body.classList.add(`home-hidden-${i.name}`)}}};(async()=>{if(!i()){return}const e=(async()=>{const e=getCookieValue("i-wanna-go-back")==="-1";const n=document.URL!=="https://www.bilibili.com/";if(!e){var i;const e=await SpinQuery.condition((()=>dqa(".proxy-box > div")),(e=>e.length>0||n));return(i=e===null||e===void 0?void 0:e.map((e=>{var n,i,t;return{name:e.id.replace(/^bili_/,""),displayName:(n=(i=e.querySelector("header .name"))===null||i===void 0?void 0:(t=i.textContent)===null||t===void 0?void 0:t.trim())!==null&&n!==void 0?n:"未知分区"}})))!==null&&i!==void 0?i:[]}else{var t;const e=["推广"];const i=await SpinQuery.condition((()=>dqa(".bili-grid .the-world")),(e=>e.length>3||n));console.log(i);const o=e=>{let n=e;while(n.parentElement){if(n.classList.contains("bili-grid")){return n}n=n.parentElement}return null};return(t=i===null||i===void 0?void 0:i.filter((n=>!e.includes(n.id))).map((e=>{const n=o(e);const i=e.id;if(n){n.dataset.area=i;return{name:i,displayName:i}}return null})).filter((e=>e!==null)))!==null&&t!==void 0?t:[]}})();const a=await e;t.push(...a);t.forEach(o);const s=a.map((({name:e})=>`\nbody.home-hidden-${e} .bili-layout .bili-grid[data-area="${e}"],\nbody.home-hidden-${e} .storey-box .proxy-box #bili_${e} {\n display: none !important;\n}\n`.trim())).join("\n");const d=n.import("homeHiddenStyle");n.applyImportantStyleFromText(s+d,"home-hidden-style")})();return{widget:{condition:i,content:`\n<div class="gui-settings-flat-button" style="position: relative" id="home-hidden">\n<i class="mdi mdi-24px mdi-settings"></i>\n<span>首页过滤</span>\n<div class="home-hidden-settings popup">\n<div v-for="item in items" @click="toggle(item)" :key="item.name" class="home-hidden-settings-item" :class="{ 'home-hidden': hiddenItems.includes(item.name) }">\n<i class="mdi mdi-18px mdi-eye"></i>\n<i class="mdi mdi-18px mdi-eye-off"></i>\n {{ item.displayName }}\n</div>\n</div>\n</div>\n`,success:async()=>{const n=dq("#home-hidden");new Vue({el:dq(n,".popup"),data(){return{items:t,hiddenItems:[...e.homeHiddenItems]}},watch:{hiddenItems(n){e.homeHiddenItems=[...n]}},mounted(){const e=this.$el;n.addEventListener("click",(n=>{if(n.target===e||e.contains(n.target)){return}e.classList.toggle("opened")}))},methods:{async toggle(e){const n=this.hiddenItems;const i=n.indexOf(e.name);if(i!==-1){n.splice(i,1)}else{n.push(e.name)}await this.$nextTick();o(e)}}})}}}})();
|
||||
@ -173,12 +173,13 @@ export const getDpiSourceSet = (src, baseSize, forceExtension = '') => {
|
||||
}).join(",")
|
||||
}
|
||||
export const isOffline = () => typeof offlineData !== 'undefined'
|
||||
export const getUID = () => document.cookie.replace(/(?:(?:^|.*;\s*)DedeUserID\s*\=\s*([^;]*).*$)|^.*$/, '$1')
|
||||
export const getCookieValue = (name) => document.cookie.replace(new RegExp(`(?:(?:^|.*;\\s*)${name}\\s*\\=\\s*([^;]*).*$)|^.*$`), '$1')
|
||||
export const getUID = () => getCookieValue('DedeUserID')
|
||||
export const scriptVersion = (() => {
|
||||
const match = GM.info.script.name.match(/Evolved \((.*)\)/)
|
||||
return match ? match[1] : 'Stable'
|
||||
})()
|
||||
export const getCsrf = () => document.cookie.replace(/(?:(?:^|.*;\s*)bili_jct\s*\=\s*([^;]*).*$)|^.*$/, '$1')
|
||||
export const getCsrf = () => getCookieValue('bili_jct')
|
||||
export const formatCount = (count) => {
|
||||
if (typeof count === 'string') {
|
||||
count = parseInt(count)
|
||||
|
||||
5
src/global.d.ts
vendored
5
src/global.d.ts
vendored
@ -193,10 +193,6 @@ declare global {
|
||||
}
|
||||
interface Document {
|
||||
pictureInPictureElement: HTMLElement | null
|
||||
exitPictureInPicture: () => void
|
||||
}
|
||||
interface HTMLVideoElement {
|
||||
requestPictureInPicture: () => void
|
||||
}
|
||||
const BwpElement: {
|
||||
new(): HTMLVideoElement
|
||||
@ -578,6 +574,7 @@ declare global {
|
||||
const descendingSort: <T>(itemProp: (item: T) => number) => (a: T, b: T) => number
|
||||
const getDpiSourceSet: (src: string, baseSize: number | string | { width?: number | string, height?: number | string }, extension?: string) => string
|
||||
const isOffline: () => boolean
|
||||
const getCookieValue: (name: string) => string
|
||||
const getUID: () => string
|
||||
const getCsrf: () => string
|
||||
const formatCount: (count: number | string) => string
|
||||
|
||||
@ -644,9 +644,34 @@ $media-types: (video, bangumi, cheese, live, manga, movie, ogv, article);
|
||||
@include background-color("4");
|
||||
}
|
||||
}
|
||||
|
||||
&__wrap {
|
||||
@include background-color();
|
||||
}
|
||||
}
|
||||
}
|
||||
#bilibili-footer {
|
||||
.n-drawer-container .elevator {
|
||||
@include background-color("2");
|
||||
.elevator-head {
|
||||
@include color("e");
|
||||
}
|
||||
|
||||
.elevator-core {
|
||||
&.is-active {
|
||||
@include background-color("3");
|
||||
}
|
||||
&:hover {
|
||||
@include background-color("4");
|
||||
}
|
||||
.name {
|
||||
@include color("e");
|
||||
}
|
||||
.icon {
|
||||
@include color("a");
|
||||
}
|
||||
}
|
||||
}
|
||||
#bili-footer {
|
||||
@include background-color();
|
||||
.split-line {
|
||||
@include background-color("4");
|
||||
|
||||
@ -21,6 +21,12 @@ const homeHiddenOptions: HomeHiddenOption[] = [
|
||||
height: 24px !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.bili-header__channel {
|
||||
height: 12px !important;
|
||||
}
|
||||
.bili-header__channel > * {
|
||||
display: none !important;
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
@ -29,30 +35,36 @@ const homeHiddenOptions: HomeHiddenOption[] = [
|
||||
.first-screen .space-between {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
.rcmd-box-wrap { display: none !important; }
|
||||
.bili-layout .bili-grid:first-child,
|
||||
.rcmd-box-wrap {
|
||||
display: none !important;
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: 'online', displayName: '在线列表', style: `
|
||||
name: 'online', displayName: '在线列表(旧版)', style: `
|
||||
.first-screen #reportFirst2 { display: none !important; }
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: 'ext-box', displayName: '电竞赛事', style: `
|
||||
name: 'ext-box', displayName: '赛事(旧版)', style: `
|
||||
.first-screen #reportFirst3 { display: none !important; } `,
|
||||
},
|
||||
{
|
||||
name: 'special', displayName: '特别推荐', style: `
|
||||
name: 'special', displayName: '特别推荐(旧版)', style: `
|
||||
#bili_report_spe_rec { display: none !important; }
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: 'contact', displayName: '联系方式', style: `
|
||||
.international-footer { display: none !important; }
|
||||
.bili-footer .b-footer-wrap,
|
||||
.international-footer {
|
||||
display: none !important;
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: 'elevator', displayName: '右侧分区导航', style: `
|
||||
name: 'elevator', displayName: '右侧分区导航(旧版)', style: `
|
||||
.storey-box .elevator { display: none !important; }
|
||||
`,
|
||||
},
|
||||
@ -76,17 +88,58 @@ const syncState = (item: HomeHiddenOption) => {
|
||||
if (!isHome()) {
|
||||
return
|
||||
}
|
||||
const generatedOptions: HomeHiddenOption[] = (await SpinQuery.condition(
|
||||
() => dqa('.proxy-box > div'),
|
||||
elements => elements.length > 0 || document.URL !== 'https://www.bilibili.com/',
|
||||
)).map(it => ({
|
||||
name: it.id.replace(/^bili_/, ''),
|
||||
displayName: it.querySelector('header .name')?.textContent?.trim() ?? '未知分区',
|
||||
}))
|
||||
const homeOptions: Promise<HomeHiddenOption[]> = (async () => {
|
||||
const isNewHome = getCookieValue('i-wanna-go-back') === '-1'
|
||||
const isNotHome = document.URL !== 'https://www.bilibili.com/'
|
||||
if (!isNewHome) {
|
||||
const list = await SpinQuery.condition(
|
||||
() => dqa('.proxy-box > div'),
|
||||
elements => elements.length > 0 || isNotHome,
|
||||
)
|
||||
return list?.map(it => ({
|
||||
name: it.id.replace(/^bili_/, ''),
|
||||
displayName: it.querySelector('header .name')?.textContent?.trim() ?? '未知分区',
|
||||
})) ?? []
|
||||
} else {
|
||||
const skipIds = ['推广']
|
||||
const headers = await SpinQuery.condition(
|
||||
() => dqa('.bili-grid .the-world'),
|
||||
elements => elements.length > 3 || isNotHome,
|
||||
)
|
||||
console.log(headers)
|
||||
const getContainer = (header: Element) => {
|
||||
let currentElement = header
|
||||
while (currentElement.parentElement) {
|
||||
if (currentElement.classList.contains('bili-grid')) {
|
||||
return currentElement
|
||||
}
|
||||
currentElement = currentElement.parentElement
|
||||
}
|
||||
return null
|
||||
}
|
||||
return headers
|
||||
?.filter(element => !skipIds.includes(element.id))
|
||||
.map(element => {
|
||||
const container = getContainer(element) as HTMLElement
|
||||
const name = element.id
|
||||
if (container) {
|
||||
container.dataset.area = name
|
||||
return {
|
||||
name,
|
||||
displayName: name,
|
||||
}
|
||||
}
|
||||
return null
|
||||
})
|
||||
.filter((it): it is HomeHiddenOption => it !== null) ?? []
|
||||
}
|
||||
})()
|
||||
const generatedOptions = await homeOptions
|
||||
homeHiddenOptions.push(...generatedOptions)
|
||||
homeHiddenOptions.forEach(syncState)
|
||||
const generatedStyles = generatedOptions.map(({ name }) => {
|
||||
return `
|
||||
body.home-hidden-${name} .bili-layout .bili-grid[data-area="${name}"],
|
||||
body.home-hidden-${name} .storey-box .proxy-box #bili_${name} {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user