mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
2.1 KiB
JavaScript
1 line
2.1 KiB
JavaScript
(()=>{return(e,t)=>{const r="bb-comment";const o=[];const n=[];const s=[];const c=[];const i=e=>{const t=e.querySelector(".con .user .name");const r=e=>{const t=e.querySelector(".reply-face");const r=e.querySelector(".reply-con .user .name");return{id:e.getAttribute("data-id"),element:e,userID:t.getAttribute("data-usercard-mid"),userName:r.textContent,content:e.querySelector(".text-con").textContent,timeText:e.querySelector(".info .time").textContent,likes:parseInt(e.querySelector(".info .like span").textContent)}};const o={id:e.getAttribute("data-id"),element:e,userID:t.getAttribute("data-usercard-mid"),userName:t.textContent,content:e.querySelector(".con .text").textContent,timeText:e.querySelector(".con .info .time").textContent,likes:parseInt(e.querySelector(".con .like span").textContent),replies:[]};if(dq(e,".reply-box .view-more")){const t=dq(e,".reply-box");Observer.childList(t,t=>{o.replies=dqa(e,".reply-box .reply-item").map(r);if(t.length!==0){o.onRepliesUpdate&&o.onRepliesUpdate(o.replies)}})}else{o.replies=dqa(e,".reply-box .reply-item").map(r)}return o};const a=e=>{if(e.observer){return}e.items=dqa(e.element,".list-item.reply-wrap").map(i);e.items.forEach(e=>{n.forEach(t=>t(e))});e.observer=Observer.childListSubtree(e.element,t=>{t.forEach(t=>{const r=e=>{return e instanceof HTMLElement&&e.classList.contains("list-item")&&e.classList.contains("reply-wrap")};t.addedNodes.forEach(t=>{if(r(t)){const r=i(t);e.items.push(r);n.forEach(e=>e(r))}});t.removedNodes.forEach(t=>{if(r(t)){const r=t.getAttribute("data-id");const o=e.items.findIndex(e=>e.id===r);if(o!==-1){const[t]=e.items.splice(o,1);s.forEach(e=>e(t))}}})})})};const l=e=>{if(e instanceof HTMLElement&&e.classList.contains(r)){const t={element:e,items:[]};o.push(t);a(t);c.forEach(e=>e(t))}};const d=e=>{o.forEach(t=>e(t));c.push(e)};const m=e=>{const{added:t,removed:r}=e;d(e=>{if(t){e.items.forEach(e=>t(e));n.push(t)}if(r){s.push(r)}})};Observer.childListSubtree(document.body,e=>{e.forEach(e=>{e.addedNodes.forEach(e=>l(e))})});dqa("."+r).forEach(l);return{export:{commentAreas:o,forEachCommentArea:d,forEachCommentItem:m}}}})(); |