Fix feeds apis in space

This commit is contained in:
the1812 2020-06-08 22:45:30 +08:00
parent 7b60953aeb
commit 252c52f315
11 changed files with 72 additions and 44 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -58,12 +58,11 @@
"danmaku-send-bar.min.css": "3FA93C0897014E89A8F904407CD6404AB9A15148D6BEB1334939F69A87ADF845",
"danmaku-send-bar.min.js": "7108E72F00C169F26E20409F4AA79F05553310375BABC392EB7E2166224B800A",
"dark.min.css": "82896BF2B40F8BABD68EF332F8CFB6F162855F2630CFC9E23B6864BE6975FC8F",
"dark.user.css": "604812CF1A4F85DD981F6B1C7F0867A89C7543F8E2E1338E65AB5F9E73B8D3E4",
"dark.user.css": "060885E9E2F1CA503493BAA49DB6F4D50DC39B4A30517454F670E054A2688ADF",
"dark-color-scheme.min.js": "6D353AC738180317ACF9D2E046BFFBA0ACC0FA7A8D22B8E16C51127CDE4FE96B",
"dark-important.min.css": "5369385A2C16188FB11E71C4C5B91275646F22F0F09E518E37813CC4FA23A072",
"dark-navbar.min.css": "7FAD547E326B768904B3739C978DF86FFDDD5E5064FB8F490710D197CCC3018B",
"dark-schedule.min.js": "853C446547603F4F0425F19F09F73335C9EC451A790C1C07E5E5B88A09E9B453",
"dark-slice-9.min.css": "7517B3DDD58CE3D6A47BB1C08509F6E6F5476D16D6E0DA4CFD61D2635765A324",
"dark-styles.min.js": "74E6D655F88E50A27D60F189554F6656CCD2A6EA2686FD9946CA9A89EABF7719",
"debounce.min.js": "54D33E1273C1F3FE19550BF1844339C3D54D6B01DF8A39C3162D95B93B079CFA",
"default-danmaku-settings.min.css": "D9942B184FEDA7B08CFA0C34920E97D7A83B81762DCBF757642EBB60F95FF25D",
@ -91,7 +90,7 @@
"extend-feeds-live.min.css": "3C22AA3BA22548D09BCE693DB4DBCB016C62C329CFB3115D6D33808798F26253",
"extend-feeds-live.min.js": "EDCA060A7DDF3339CCB1F8A0D4360FE1016FD78B0FDEDCB4CBDB7280895FF5F6",
"favorites-redirect.min.js": "70D6ECCE0402AA76387D2A3288C1148C60CC88D5378B7A2BDC813F3F78E4EE84",
"feeds-apis.min.js": "D82FA6F7CEE6AB2CB173764E2F8F8C6D877B1A9C7098A2EC125F13CB0EF6C9DF",
"feeds-apis.min.js": "6F882E0B2B11820E66EF0643C2C3DE71EDF76894F1771EEDF2B256AD7DBD8C14",
"feeds-filter.min.js": "9E8BC1A669D97992E888A3154FCE64912CE0B7A303D6BE40C3CA0C71A9533B96",
"feeds-filter-card.vue.min.js": "E995F9C93BA50983AAAFB2DE45848769C78FC0E39A34655FA98586DFE670670B",
"feeds-translate.min.css": "704EF1AAE13C4F7D33244E0EC30069AE449C4DBA0310E94C6A6B6ECC33570E5E",
@ -103,7 +102,7 @@
"fixed-sidebars.min.js": "409B25F94CD87A1136A77A4F49F83AB933D49D0E5DFD04F883EEA9AE922D923B",
"fix-fullscreen.min.js": "C0628A7CABB4421FCBD7663700EF9965C96F6D79979B9F7523A9F9B0B009C8B6",
"fold-comment.min.css": "74DF4566EB80AD7078E65E8B68633E05FC41D3B4E47A20D6E415E8A743F35378",
"fold-comment.min.js": "0CFE018D920A5E31513911438EF28577CABC908B28BCB40F0148F579F4530A10",
"fold-comment.min.js": "F061ED1A92BF07CA00AAFC1CC188FE56857B3C7F70EA45AD6024643F872386BB",
"frame-playback.min.css": "45AC8DEBA1DEE2708FB19F8ED72798294A96A341F4FAFAFAFDEAFB79CFB50368",
"frame-playback.min.html": "4089BD1D954155EA91D39C33E22D7585A87C3F8A9B4A6BA4CE5D97B51763C971",
"frame-playback.min.js": "57B34757FD03B9164B27DB48A1D6F4E3633086C27CD1E3246FCEDDCD7768F05E",

Binary file not shown.

View File

@ -3,7 +3,7 @@
@namespace Bilibili-Evolved
@homepageURL https://github.com/the1812/Bilibili-Evolved
@updateURL https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@preview/min/dark.user.css
@version 692.89.0
@version 693.28.0
@license MIT
@author Grant Howard (https://github.com/the1812), Coulomb-G (https://github.com/Coulomb-G)
==/UserStyle== */

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(()=>{return(e,t)=>{(async()=>{if(document.URL.replace(window.location.search,"")!=="https://t.bilibili.com/"&&!document.URL.startsWith("https://space.bilibili.com")){return}const e=await SpinQuery.select(".feed-card > .content");if(!e){return}t.applyImportantStyle("foldCommentStyle");const n=e=>{const t=t=>{const n=document.createElement("div");n.classList.add("fold-comment");n.innerHTML="收起评论";const l=t.querySelector(".bb-comment");if(l===null){console.error("未找到评论区");return}else if(l.querySelector(".fold-comment")!==null){return}else{n.addEventListener("click",()=>{const t=e.querySelector(".button-bar").children[1];if(t!==null){t.click();e.scrollIntoView()}});l.insertAdjacentElement("beforeend",n)}};const n=e.querySelector(".panel-area");if(n===null){console.log(e)}if(n.childElementCount===0){const e=Observer.childList(n,l=>{if(l.length>0){t(n);e.forEach(e=>e.stop())}})}else{t(n)}};Observer.childList(e,()=>e.querySelectorAll("div.card").forEach(n))})()}})();
(()=>{return(e,t)=>{(async()=>{if(document.URL.replace(window.location.search,"")!=="https://t.bilibili.com/"&&!document.URL.startsWith("https://space.bilibili.com")){return}const{feedsCardsManager:e}=await t.importAsync("feeds-apis");const n=await e.startWatching();if(!n){console.error("feedsCardsManager.startWatching() failed");return}t.applyImportantStyle("foldCommentStyle");const r=e=>{const t=t=>{const n=document.createElement("div");n.classList.add("fold-comment");n.innerHTML="收起评论";const r=t.querySelector(".bb-comment");if(r===null){console.error("未找到评论区");return}else if(r.querySelector(".fold-comment")!==null){return}else{n.addEventListener("click",()=>{const t=e.querySelector(".button-bar").children[1];if(t!==null){t.click();e.scrollIntoView()}});r.insertAdjacentElement("beforeend",n)}};const n=e.querySelector(".panel-area");if(n===null){console.log(e)}if(n.childElementCount===0){const e=Observer.childList(n,r=>{if(r.length>0){t(n);e.forEach(e=>e.stop())}})}else{t(n)}};e.cards.forEach(e=>r(e.element));e.addEventListener("addCard",e=>r(e.detail.element))})()}})();

View File

@ -256,22 +256,52 @@ class FeedsCardsManager extends EventTarget {
return card
}
async startWatching() {
const updateCards = (cardsList: HTMLElement) => {
const cards = [...cardsList.querySelectorAll('.content>.card')]
cards.forEach(it => this.addCard(it))
return Observer.childList(cardsList, records => {
records.forEach(record => {
record.addedNodes.forEach(node => this.addCard(node))
record.removedNodes.forEach(node => this.removeCard(node))
})
})
}
if (this.watching) {
return true
}
if (document.URL.includes('//space.bilibili.com')) {
console.log('space watch')
const container = await SpinQuery.select('.s-space') as HTMLDivElement
if (!container) {
return false
}
let cardListObserver: Observer | null = null
Observer.childList(container, async () => {
if (dq('#page-dynamic')) {
const cardsList = await SpinQuery.select('.feed-card .content') as HTMLElement
console.log('enter feeds tab')
if (cardListObserver) {
cardListObserver.stop()
}
cardListObserver = updateCards(cardsList)
} else {
console.log('leave feeds tab')
if (cardListObserver) {
cardListObserver.stop()
cardListObserver = null
}
}
})
this.watching = true
return true
}
const cardsList = await SpinQuery.select('.feed-card .content') as HTMLDivElement
if (!cardsList) {
return false
}
if (this.watching) {
return true
}
updateCards(cardsList)
this.watching = true
const cards = [...cardsList.querySelectorAll('.content>.card')]
cards.forEach(it => this.addCard(it))
Observer.childList(cardsList, records => {
records.forEach(record => {
record.addedNodes.forEach(node => this.addCard(node))
record.removedNodes.forEach(node => this.removeCard(node))
})
})
return true
}
}

View File

@ -3,12 +3,14 @@
&& !document.URL.startsWith('https://space.bilibili.com')) {
return
}
const cardList = await SpinQuery.select('.feed-card > .content') as HTMLDivElement
if (!cardList) {
const { feedsCardsManager } = await import('../feeds-apis')
const success = await feedsCardsManager.startWatching()
if (!success) {
console.error('feedsCardsManager.startWatching() failed')
return
}
resources.applyImportantStyle('foldCommentStyle')
const injectButton = (card: HTMLDivElement) => {
const injectButton = (card: HTMLElement) => {
const injectToComment = (panelArea: HTMLDivElement) => {
const button = document.createElement('div')
button.classList.add('fold-comment')
@ -45,5 +47,6 @@
injectToComment(panelArea)
}
}
Observer.childList(cardList, () => cardList.querySelectorAll('div.card').forEach(injectButton))
feedsCardsManager.cards.forEach(c => injectButton(c.element))
feedsCardsManager.addEventListener('addCard', e => injectButton(e.detail.element))
})()