Bilibili-Evolved/min/fold-comment.min.js
2021-10-26 13:22:15 +08:00

1 line
1.0 KiB
JavaScript

(()=>(e,t)=>{(async()=>{const e=document.URL.includes("//t.bilibili.com")&&document.URL.replace(window.location.search,"")!=="https://t.bilibili.com/";const n=document.URL.startsWith("https://t.bilibili.com/topic/");if(e&&!n){return}const{forEachFeedsCard:o,supportedUrls:l}=await t.importAsync("feeds-apis");if(l.every((e=>!document.URL.includes(e)))){return}t.applyImportantStyle("foldCommentStyle");const c=e=>{const t=t=>{const n=document.createElement("div");n.classList.add("fold-comment");n.innerHTML="收起评论";const o=t.querySelector(".bb-comment");if(o===null){console.error("未找到评论区");return}else if(o.querySelector(".fold-comment")!==null){return}else{n.addEventListener("click",(()=>{const t=e.querySelector(".button-bar").children[1];if(t!==null){t.click();e.scrollIntoView()}}));o.insertAdjacentElement("beforeend",n)}};const n=e.querySelector(".panel-area");if(n===null){console.log(e)}if(n.childElementCount===0){const e=Observer.childList(n,(o=>{if(o.length>0){t(n);e.forEach((e=>e.stop()))}}))}else{t(n)}};o({added:e=>c(e.element)})})()})();