mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Fix bug when watchlater list is empty
This commit is contained in:
parent
87da33b2ae
commit
3714f8f3fc
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name Bilibili Evolved (Offline)
|
||||
// @version 390.31
|
||||
// @version 390.33
|
||||
// @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中.
|
||||
// @author Grant Howard, Coulomb-G
|
||||
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
||||
@ -1107,7 +1107,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-info.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.aid=t}async fetchInfo(){const t=JSON.parse(await Ajax.getText(`https://api.bilibili.com/x/web-interface/view?aid=${this.aid}`));if(t.code!==0){throw new Error(t.message)}const i=t.data;this.cid=i.cid;this.pageCount=i.videos;this.coverUrl=i.pic;this.tagId=i.tid;this.tagName=i.tname;this.title=i.title;this.description=i.desc;this.up={uid:i.owner.mid,name:i.owner.name,faceUrl:i.owner.face};this.pages=i.pages.map(t=>{return{cid:t.cid,title:t.part,pageNumber:t.page}});return this}async fetchDanmaku(){this.danmaku=new s(this.cid.toString());return this.danmaku.fetchInfo()}}class a{constructor(t,i){this.text=t;this.p=i}}class s{constructor(t){this.cid=t}async fetchInfo(){const t=await Ajax.getText(`https://api.bilibili.com/x/v1/dm/list.so?oid=${this.cid}`);this.rawXML=t;const i=(new DOMParser).parseFromString(t,"application/xml").documentElement;this.xml=i;this.danmakus=[...i.querySelectorAll("d[p]")].map(t=>{return new a(t.innerHTML,t.getAttribute("p"))})}}class n{constructor(t){this.ep=t;this.videos=[]}async fetchInfo(){const t=await Ajax.getText(`https://www.bilibili.com/bangumi/play/ep${this.ep}/`);const i=JSON.parse(t.match(/window\.__INITIAL_STATE__=(.*);\(function\(\){/)[1]);this.title=i.mediaInfo.title;this.cover=i.mediaInfo.cover;this.squareCover=i.mediaInfo.square_cover;this.aid=i.epInfo.aid;this.cid=i.epInfo.cid;this.videos=i.epList.map(async t=>{return{title:t.index_title,aid:t.aid,cid:t.cid,info:await new e(t.aid).fetchInfo()}});return this}}return{export:{VideoInfo:e,BangumiInfo:n,Danmaku:a,DanmakuInfo:s}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-story.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.title=t.option;this.nodeID=t.node_id;this.cid=t.cid;this.default=t.is_default===1}}class s{constructor(t,i,e){this.title=t.title;this.nodeID=t.node_id;this.aid=i;this.cid=t.cid;this.graphVersion=e;this.choices=[];this.choiceTime=-1}async getChoices(){if(this.choices.length>0){return}const t=`https://api.bilibili.com/x/stein/nodeinfo?aid=${this.aid}&node_id=${this.nodeID}&graph_version=504`;const i=await Ajax.getJsonWithCredentials(t);if(i.code!==0){console.error(`获取选项失败: ${i.message}`);return}this.choices=i.data.edges.choices.map(t=>new e(t))}}class o{constructor(t,i){this.nodeList=t;if(i){this.startingNode=i}else{[this.startingNode]=t}}async getAllChoices(){return await Promise.all(this.nodeList.map(t=>t.getChoices()))}}const n=async(t,i)=>{const n=`https://api.bilibili.com/x/stein/nodeinfo?aid=${t}&graph_version=${i}`;const c=await Ajax.getJsonWithCredentials(n);if(c.code!==0){return c.message}const a=c.data.story_list.map(e=>new s(e,t,i));const d=a.find(t=>t.nodeID===c.data.node_id);if(!d){return"获取起始结点失败"}d.choiceTime=c.data.edges.show_time;const r=c.data.edges.choices.map(t=>new e(t));d.choices=r;return new o(a,d)};return{export:{StoryChoice:e,StoryNode:s,Story:o,getStoryNodes:n}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if(document.querySelector(".image-viewer")===null){this.createContainer()}this.viewer=document.querySelector(".image-viewer-container");this.downloadImage();addSettingsListener("filenameFormat",()=>{this.viewer.querySelector(".download").setAttribute("download",this.filename)})}createContainer(){document.body.insertAdjacentHTML("beforeend",t.import("imageViewerHtml"));document.querySelector(".image-viewer-container .close").addEventListener("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){document.querySelector("#view-cover").style.display=this.url?"flex":"none";if(this.url===""){return}const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=t;const i=this.viewer.querySelector(".download");i.setAttribute("href",t);i.setAttribute("download",this.filename);this.viewer.querySelector(".copy-link").addEventListener("click",()=>GM_setClipboard(this.url));this.viewer.querySelector(".new-tab").setAttribute("href",this.url);this.viewer.querySelector(".image").src=t});e.send()}show(){this.viewer.classList.add("opened")}hide(){this.viewer.classList.remove("opened")}get filename(){return n(document.URL.includes("/www.bilibili.com/bangumi/"))+this.url.substring(this.url.lastIndexOf("."))}}return(()=>{if(!document.URL.includes("live.bilibili.com")){return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="view-cover">\n <i class="icon-view"></i>\n <span>查看封面</span>\n </button>`,condition:async()=>{const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);return Boolean(e)},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new i(e);try{await t.fetchInfo()}catch(e){return""}return t.coverUrl}let t=new o(await e());document.querySelector("#view-cover").addEventListener("click",()=>{t.show()});const n=async()=>{t=new o(await e())};Observer.videoChange(n)}}}}else{return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="view-cover">\n <i class="icon-view"></i>\n <span>查看封面</span>\n </button>`,condition:async()=>{const e=await SpinQuery.select(()=>document.querySelector(".header-info-ctnr .room-cover"));return Boolean(e)},success:async()=>{const e=document.querySelector(".header-info-ctnr .room-cover");const t=e.getAttribute("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const i=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const n=await Ajax.getJson(i);const r=n.data.cover;const s=new o(r);document.querySelector("#view-cover").addEventListener("click",()=>{s.show()})}}}}}})()}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater-api.min.js"] = (()=>{return(t,i)=>{const e=async(t,i)=>{const e=i?"https://api.bilibili.com/x/v2/history/toview/add":"https://api.bilibili.com/x/v2/history/toview/del";const s=document.cookie.replace(/(?:(?:^|.*\s*)bili_jct\s*\=\s*([^]*).*$)|^.*$/,"$1");const a=await Ajax.postTextWithCredentials(e,`aid=${t}&csrf=${s}`);const o=JSON.parse(a);if(o.code!==0){throw new Error(`稍后再看操作失败: ${o.message}`)}};const s=async(t=false)=>{const i=`https://api.bilibili.com/x/v2/history/toview/web`;const e=await Ajax.getJsonWithCredentials(i);if(e.code!==0){throw new Error(`获取稍后再看列表失败: ${e.message}`)}if(t===true){return e.data}return e.data.list.map(t=>t.aid)};return{export:{toggleWatchlater:e,getWatchlaterList:s}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater-api.min.js"] = (()=>{return(t,i)=>{const e=async(t,i)=>{const e=i?"https://api.bilibili.com/x/v2/history/toview/add":"https://api.bilibili.com/x/v2/history/toview/del";const s=document.cookie.replace(/(?:(?:^|.*\s*)bili_jct\s*\=\s*([^]*).*$)|^.*$/,"$1");const a=await Ajax.postTextWithCredentials(e,`aid=${t}&csrf=${s}`);const o=JSON.parse(a);if(o.code!==0){throw new Error(`稍后再看操作失败: ${o.message}`)}};const s=async(t=false)=>{const i=`https://api.bilibili.com/x/v2/history/toview/web`;const e=await Ajax.getJsonWithCredentials(i);if(e.code!==0){throw new Error(`获取稍后再看列表失败: ${e.message}`)}if(t===true){return e.data}if(!e.data.list){return[]}return e.data.list.map(t=>t.aid)};return{export:{toggleWatchlater:e,getWatchlaterList:s}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return(e,t)=>{const r=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const a=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return r(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,r)=>$(e).attr("href",t[r]).attr("target","_blank"))};const i=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>a([...e]))}};SpinQuery.any(()=>$(".watch-later-list"),()=>{(Observer.childListSubtree||Observer.subtree)("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=r(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.any(()=>$("#viewlater-app .s-btn[href='#/']"),e=>e.remove());i(".av-pic",".av-about>a")})});SpinQuery.any(()=>$("li.nav-item[report-id*=watchlater]"),()=>{(Observer.childListSubtree||Observer.subtree)("li.nav-item[report-id*=watchlater]",()=>{i(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.any(()=>$(".read-more.mr"),e=>e.remove());SpinQuery.any(()=>$(".read-more-grp>.read-more"),e=>e.css({float:"none",width:"auto"}))})})}})();
|
||||
|
||||
class ResourceType
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name Bilibili Evolved (Preview Offline)
|
||||
// @version 390.31
|
||||
// @version 390.33
|
||||
// @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中.
|
||||
// @author Grant Howard, Coulomb-G
|
||||
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
||||
@ -1107,7 +1107,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-info.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.aid=t}async fetchInfo(){const t=JSON.parse(await Ajax.getText(`https://api.bilibili.com/x/web-interface/view?aid=${this.aid}`));if(t.code!==0){throw new Error(t.message)}const i=t.data;this.cid=i.cid;this.pageCount=i.videos;this.coverUrl=i.pic;this.tagId=i.tid;this.tagName=i.tname;this.title=i.title;this.description=i.desc;this.up={uid:i.owner.mid,name:i.owner.name,faceUrl:i.owner.face};this.pages=i.pages.map(t=>{return{cid:t.cid,title:t.part,pageNumber:t.page}});return this}async fetchDanmaku(){this.danmaku=new s(this.cid.toString());return this.danmaku.fetchInfo()}}class a{constructor(t,i){this.text=t;this.p=i}}class s{constructor(t){this.cid=t}async fetchInfo(){const t=await Ajax.getText(`https://api.bilibili.com/x/v1/dm/list.so?oid=${this.cid}`);this.rawXML=t;const i=(new DOMParser).parseFromString(t,"application/xml").documentElement;this.xml=i;this.danmakus=[...i.querySelectorAll("d[p]")].map(t=>{return new a(t.innerHTML,t.getAttribute("p"))})}}class n{constructor(t){this.ep=t;this.videos=[]}async fetchInfo(){const t=await Ajax.getText(`https://www.bilibili.com/bangumi/play/ep${this.ep}/`);const i=JSON.parse(t.match(/window\.__INITIAL_STATE__=(.*);\(function\(\){/)[1]);this.title=i.mediaInfo.title;this.cover=i.mediaInfo.cover;this.squareCover=i.mediaInfo.square_cover;this.aid=i.epInfo.aid;this.cid=i.epInfo.cid;this.videos=i.epList.map(async t=>{return{title:t.index_title,aid:t.aid,cid:t.cid,info:await new e(t.aid).fetchInfo()}});return this}}return{export:{VideoInfo:e,BangumiInfo:n,Danmaku:a,DanmakuInfo:s}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-story.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.title=t.option;this.nodeID=t.node_id;this.cid=t.cid;this.default=t.is_default===1}}class s{constructor(t,i,e){this.title=t.title;this.nodeID=t.node_id;this.aid=i;this.cid=t.cid;this.graphVersion=e;this.choices=[];this.choiceTime=-1}async getChoices(){if(this.choices.length>0){return}const t=`https://api.bilibili.com/x/stein/nodeinfo?aid=${this.aid}&node_id=${this.nodeID}&graph_version=504`;const i=await Ajax.getJsonWithCredentials(t);if(i.code!==0){console.error(`获取选项失败: ${i.message}`);return}this.choices=i.data.edges.choices.map(t=>new e(t))}}class o{constructor(t,i){this.nodeList=t;if(i){this.startingNode=i}else{[this.startingNode]=t}}async getAllChoices(){return await Promise.all(this.nodeList.map(t=>t.getChoices()))}}const n=async(t,i)=>{const n=`https://api.bilibili.com/x/stein/nodeinfo?aid=${t}&graph_version=${i}`;const c=await Ajax.getJsonWithCredentials(n);if(c.code!==0){return c.message}const a=c.data.story_list.map(e=>new s(e,t,i));const d=a.find(t=>t.nodeID===c.data.node_id);if(!d){return"获取起始结点失败"}d.choiceTime=c.data.edges.show_time;const r=c.data.edges.choices.map(t=>new e(t));d.choices=r;return new o(a,d)};return{export:{StoryChoice:e,StoryNode:s,Story:o,getStoryNodes:n}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if(document.querySelector(".image-viewer")===null){this.createContainer()}this.viewer=document.querySelector(".image-viewer-container");this.downloadImage();addSettingsListener("filenameFormat",()=>{this.viewer.querySelector(".download").setAttribute("download",this.filename)})}createContainer(){document.body.insertAdjacentHTML("beforeend",t.import("imageViewerHtml"));document.querySelector(".image-viewer-container .close").addEventListener("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){document.querySelector("#view-cover").style.display=this.url?"flex":"none";if(this.url===""){return}const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=t;const i=this.viewer.querySelector(".download");i.setAttribute("href",t);i.setAttribute("download",this.filename);this.viewer.querySelector(".copy-link").addEventListener("click",()=>GM_setClipboard(this.url));this.viewer.querySelector(".new-tab").setAttribute("href",this.url);this.viewer.querySelector(".image").src=t});e.send()}show(){this.viewer.classList.add("opened")}hide(){this.viewer.classList.remove("opened")}get filename(){return n(document.URL.includes("/www.bilibili.com/bangumi/"))+this.url.substring(this.url.lastIndexOf("."))}}return(()=>{if(!document.URL.includes("live.bilibili.com")){return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="view-cover">\n <i class="icon-view"></i>\n <span>查看封面</span>\n </button>`,condition:async()=>{const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);return Boolean(e)},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new i(e);try{await t.fetchInfo()}catch(e){return""}return t.coverUrl}let t=new o(await e());document.querySelector("#view-cover").addEventListener("click",()=>{t.show()});const n=async()=>{t=new o(await e())};Observer.videoChange(n)}}}}else{return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="view-cover">\n <i class="icon-view"></i>\n <span>查看封面</span>\n </button>`,condition:async()=>{const e=await SpinQuery.select(()=>document.querySelector(".header-info-ctnr .room-cover"));return Boolean(e)},success:async()=>{const e=document.querySelector(".header-info-ctnr .room-cover");const t=e.getAttribute("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const i=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const n=await Ajax.getJson(i);const r=n.data.cover;const s=new o(r);document.querySelector("#view-cover").addEventListener("click",()=>{s.show()})}}}}}})()}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater-api.min.js"] = (()=>{return(t,i)=>{const e=async(t,i)=>{const e=i?"https://api.bilibili.com/x/v2/history/toview/add":"https://api.bilibili.com/x/v2/history/toview/del";const s=document.cookie.replace(/(?:(?:^|.*\s*)bili_jct\s*\=\s*([^]*).*$)|^.*$/,"$1");const a=await Ajax.postTextWithCredentials(e,`aid=${t}&csrf=${s}`);const o=JSON.parse(a);if(o.code!==0){throw new Error(`稍后再看操作失败: ${o.message}`)}};const s=async(t=false)=>{const i=`https://api.bilibili.com/x/v2/history/toview/web`;const e=await Ajax.getJsonWithCredentials(i);if(e.code!==0){throw new Error(`获取稍后再看列表失败: ${e.message}`)}if(t===true){return e.data}return e.data.list.map(t=>t.aid)};return{export:{toggleWatchlater:e,getWatchlaterList:s}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater-api.min.js"] = (()=>{return(t,i)=>{const e=async(t,i)=>{const e=i?"https://api.bilibili.com/x/v2/history/toview/add":"https://api.bilibili.com/x/v2/history/toview/del";const s=document.cookie.replace(/(?:(?:^|.*\s*)bili_jct\s*\=\s*([^]*).*$)|^.*$/,"$1");const a=await Ajax.postTextWithCredentials(e,`aid=${t}&csrf=${s}`);const o=JSON.parse(a);if(o.code!==0){throw new Error(`稍后再看操作失败: ${o.message}`)}};const s=async(t=false)=>{const i=`https://api.bilibili.com/x/v2/history/toview/web`;const e=await Ajax.getJsonWithCredentials(i);if(e.code!==0){throw new Error(`获取稍后再看列表失败: ${e.message}`)}if(t===true){return e.data}if(!e.data.list){return[]}return e.data.list.map(t=>t.aid)};return{export:{toggleWatchlater:e,getWatchlaterList:s}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return(e,t)=>{const r=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const a=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return r(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,r)=>$(e).attr("href",t[r]).attr("target","_blank"))};const i=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>a([...e]))}};SpinQuery.any(()=>$(".watch-later-list"),()=>{(Observer.childListSubtree||Observer.subtree)("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=r(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.any(()=>$("#viewlater-app .s-btn[href='#/']"),e=>e.remove());i(".av-pic",".av-about>a")})});SpinQuery.any(()=>$("li.nav-item[report-id*=watchlater]"),()=>{(Observer.childListSubtree||Observer.subtree)("li.nav-item[report-id*=watchlater]",()=>{i(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.any(()=>$(".read-more.mr"),e=>e.remove());SpinQuery.any(()=>$(".read-more-grp>.read-more"),e=>e.css({float:"none",width:"auto"}))})})}})();
|
||||
|
||||
class ResourceType
|
||||
|
||||
2
min/watchlater-api.min.js
vendored
2
min/watchlater-api.min.js
vendored
@ -1 +1 @@
|
||||
(()=>{return(t,i)=>{const e=async(t,i)=>{const e=i?"https://api.bilibili.com/x/v2/history/toview/add":"https://api.bilibili.com/x/v2/history/toview/del";const s=document.cookie.replace(/(?:(?:^|.*\s*)bili_jct\s*\=\s*([^]*).*$)|^.*$/,"$1");const a=await Ajax.postTextWithCredentials(e,`aid=${t}&csrf=${s}`);const o=JSON.parse(a);if(o.code!==0){throw new Error(`稍后再看操作失败: ${o.message}`)}};const s=async(t=false)=>{const i=`https://api.bilibili.com/x/v2/history/toview/web`;const e=await Ajax.getJsonWithCredentials(i);if(e.code!==0){throw new Error(`获取稍后再看列表失败: ${e.message}`)}if(t===true){return e.data}return e.data.list.map(t=>t.aid)};return{export:{toggleWatchlater:e,getWatchlaterList:s}}}})();
|
||||
(()=>{return(t,i)=>{const e=async(t,i)=>{const e=i?"https://api.bilibili.com/x/v2/history/toview/add":"https://api.bilibili.com/x/v2/history/toview/del";const s=document.cookie.replace(/(?:(?:^|.*\s*)bili_jct\s*\=\s*([^]*).*$)|^.*$/,"$1");const a=await Ajax.postTextWithCredentials(e,`aid=${t}&csrf=${s}`);const o=JSON.parse(a);if(o.code!==0){throw new Error(`稍后再看操作失败: ${o.message}`)}};const s=async(t=false)=>{const i=`https://api.bilibili.com/x/v2/history/toview/web`;const e=await Ajax.getJsonWithCredentials(i);if(e.code!==0){throw new Error(`获取稍后再看列表失败: ${e.message}`)}if(t===true){return e.data}if(!e.data.list){return[]}return e.data.list.map(t=>t.aid)};return{export:{toggleWatchlater:e,getWatchlaterList:s}}}})();
|
||||
@ -1057,7 +1057,7 @@ class Activities extends NavbarComponent {
|
||||
}
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
async mounted () {
|
||||
// 预加载稍后再看的API
|
||||
await import('../../video/watchlater-api')
|
||||
},
|
||||
@ -1109,12 +1109,6 @@ class Activities extends NavbarComponent {
|
||||
const watchlaterList = await getWatchlaterList()
|
||||
const cards = json.data.cards.map(card => {
|
||||
const cardJson = JSON.parse(card.card)
|
||||
// let topics
|
||||
// if (card.display && card.display.topic_info) {
|
||||
// topics = card.display.topic_info.topic_details.map(it => {
|
||||
// return it.topic_name
|
||||
// })
|
||||
// }
|
||||
return {
|
||||
coverUrl: cardJson.pic,
|
||||
title: cardJson.title,
|
||||
@ -1127,9 +1121,8 @@ class Activities extends NavbarComponent {
|
||||
upName: card.desc.user_profile.info.uname,
|
||||
upUrl: `https://space.bilibili.com/${card.desc.user_profile.info.uid}`,
|
||||
id: card.desc.dynamic_id_str,
|
||||
// topics,
|
||||
watchlater: watchlaterList.includes(cardJson.aid),
|
||||
get new() { return Activities.isNewID(this.id) },
|
||||
get new () { return Activities.isNewID(this.id) },
|
||||
}
|
||||
})
|
||||
this.leftCards = cards.filter((_, index) => index % 2 === 0)
|
||||
|
||||
@ -19,6 +19,9 @@ export const getWatchlaterList = async (raw = false) => {
|
||||
if (raw === true) {
|
||||
return response.data
|
||||
}
|
||||
if (!response.data.list) {
|
||||
return []
|
||||
}
|
||||
return response.data.list.map((item: any) => item.aid)
|
||||
}
|
||||
export default {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user