mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
1.4 KiB
JavaScript
1 line
1.4 KiB
JavaScript
(()=>{return(t,e)=>{(async()=>{if(!document.URL.startsWith("https://www.bilibili.com/video/")||!getUID()){return}await SpinQuery.condition(()=>dq(".video-toolbar .ops .collect"),t=>{return t!==null&&t.innerText!=="--"});const t=dq(".video-toolbar .ops .collect");if(!t){return}e.applyStyle("outerWatchlaterStyle");t.insertAdjacentHTML("afterend",`\n<span title='稍后再看' class='watchlater' :class="{on: isInWatchlater}" @click="toggle()">\n<i class='mdi mdi-timetable'></i>\n 稍后再看\n<div class='tip' :class="{show: tipShowing}">{{tipText}}</div>\n</span>\n`);const i=dq(".ops .watchlater");if(!i){return}const a=new Vue({el:i,store:store,data:{aid:unsafeWindow.aid,tipText:"",tipShowing:false,tipHandle:0},computed:{...Vuex.mapState(["watchlaterList"]),isInWatchlater(){return this.watchlaterList.includes(parseInt(this.aid))}},methods:{...Vuex.mapActions(["toggleWatchlater"]),showTip(t){this.tipText=t;this.tipShowing=true;if(this.tipHandle){clearTimeout(this.tipHandle)}this.tipHandle=setTimeout(()=>{this.tipShowing=false},2e3)},async toggle(){await this.toggleWatchlater(this.aid);this.showTip(this.isInWatchlater?"已添加至稍后再看":"已从稍后再看移除")}}});Observer.videoChange(()=>{a.aid=unsafeWindow.aid})})();return{unload:()=>{dqa(".ops .watchlater").forEach(t=>t.style.display="none")},reload:()=>{dqa(".ops .watchlater").forEach(t=>t.style.display="inline-block")}}}})(); |