Bilibili-Evolved/min/watchlater.min.js
2020-03-23 16:32:46 +08:00

1 line
2.0 KiB
JavaScript

(()=>{return(t,e)=>{const i=t=>{const e=t.match(/(av[\d]+)\/p([\d]+)/i)||t.match(/(BV[\w]+)\/p([\d]+)/i);if(e){return`https://www.bilibili.com/video/${e[1]}/?p=${e[2]}`}else{return"javascript:;"}};const r=t=>{const e=t.map(t=>{const e=t.getAttribute("href");if(!e){return"javascript:;"}if(e.match(/.*watchlater.*|javascript:;/g)){return i(e)}if(e.match(/video\/av|video\/BV/i)){return e}});t.forEach((t,i)=>{t.setAttribute("href",e[i]);t.setAttribute("target","_blank")})};const a=(...t)=>{for(const e of t){SpinQuery.select(()=>document.querySelectorAll(e),t=>r([...t]))}};SpinQuery.select(".watch-later-list").then(()=>{Observer.childListSubtree("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/i)||document.URL.match(/(BV[\w]+)\/p([\d]+)/i),t=>t&&document.URL.indexOf("watchlater")!==-1,()=>{const t=i(document.URL);if(t!==null){window.location.assign(t)}});SpinQuery.select("#viewlater-app .s-btn[href='#/']",t=>t.remove());a(".av-pic",".av-about>a")})});SpinQuery.select("li.nav-item[report-id*=watchlater]").then(()=>{Observer.childListSubtree("li.nav-item[report-id*=watchlater]",()=>{a(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.select(".read-more.mr",t=>t.remove());SpinQuery.select(".read-more-grp>.read-more",t=>{t.style.width="auto";t.style.float="none"})})});SpinQuery.select(".van-popper-favorite").then(async t=>{if(!t){return}const e=Observer.childListSubtree(t,()=>{const i=t.querySelector(".play-all");if(i){const t="//www.bilibili.com/watchlater/#/list";Observer.attributes(i,()=>{if(i.getAttribute("href")==="//www.bilibili.com/watchlater/"){i.setAttribute("href",t);i.firstChild.classList.remove("bili-icon_dingdao_bofang");i.firstChild.classList.add("bili-icon_xinxi_yuedushu");i.lastChild.nodeValue="查看全部"}else if(i.getAttribute("href")!==t){i.firstChild.classList.add("bili-icon_dingdao_bofang");i.firstChild.classList.remove("bili-icon_xinxi_yuedushu");i.lastChild.nodeValue="播放全部"}});e.forEach(t=>t.stop())}})})}})();