Bilibili-Evolved/min/disable-feeds-details.min.js
2020-06-25 11:54:01 +08:00

1 line
1.5 KiB
JavaScript

(()=>{return(t,e)=>{let n=true;const s="disable-feeds-details-style";const a=`\n.card[data-did] .content { cursor: text }\n.card[data-did] .content .details {\n font-size: 12px;\n opacity: 0.6;\n cursor: pointer;\n display: block;\n}\n`;e.applyImportantStyleFromText(".card[data-did] .content .details { display: none }","disable-feeds-details-init-style");const i=()=>e.applyImportantStyleFromText(a,s);const c=document.URL.replace(location.search,"");const r=c.startsWith("https://t.bilibili.com/")||c.startsWith("https://space.bilibili.com/");(async()=>{if(!r){return}i();const{feedsCardsManager:t}=await e.importAsync("feeds-apis");const s=await t.startWatching();if(!s){console.error("feedsCardsManager.startWatching() failed");return}const a=t=>{const e=t.element;e.addEventListener("click",t=>{if(t.ctrlKey||!n){return}const s=dqa(e,".content");const a=t.target;if(a.hasAttribute("click-title")){return}if(s.some(t=>t===a||t.contains(a))){t.stopImmediatePropagation()}},{capture:true});const s=dq(e,".post-content");if(!s){return}if(s.classList.contains("repost")&&!dq(s,".details")){const t=dq(s,".content");const e=document.createElement("div");e.classList.add("details");e.setAttribute("click-title","详情");e.innerHTML=`\n 详情<i class="mdi mdi-chevron-right" click-title></i>\n`;t.insertAdjacentElement("beforeend",e)}};t.cards.forEach(a);t.addEventListener("addCard",t=>{const e=t.detail;a(e)})})();return{reload:()=>{if(r){i();n=true}},unload:()=>{if(r){const t=document.getElementById(s);t&&t.remove();n=false}}}}})();