{"size": 4721, "ext": "js", "max_stars_repo_path": "min/feeds-apis.min.js", "max_stars_repo_name": "WaylandGod/Bilibili-Evolved", "max_stars_repo_stars_event_min_datetime": "2021-05-04T12:18:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-04T12:18:16.000Z", "max_issues_repo_path": "min/feeds-apis.min.js", "max_issues_repo_name": "Danicaghost/Bilibili-Evolved", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "min/feeds-apis.min.js", "max_forks_repo_name": "Danicaghost/Bilibili-Evolved", "max_forks_repo_forks_event_min_datetime": "2020-05-17T14:53:05.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-17T14:53:05.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 4721.0, "max_line_length": 4721, "alphanum_fraction": 0.7422156323}
(()=>{return(e,t)=>{const i={repost:{id:1,name:"转发"},textWithImages:{id:2,name:"图文"},text:{id:4,name:"文字"},video:{id:8,name:"视频"},miniVideo:{id:16,name:"小视频"},column:{id:64,name:"专栏"},audio:{id:256,name:"音频"},bangumi:{id:512,name:"番剧"},share:{id:2048,name:"分享"},manga:{id:2049,name:"漫画"},film:{id:4098,name:"电影"},tv:{id:4099,name:"TV剧"},chinese:{id:4100,name:"国创"},documentary:{id:4101,name:"纪录片"},mediaList:{id:4300,name:"收藏夹"}};const n=e=>{if(e.querySelector(".repost")){return i.repost}if(e.querySelector(".imagesbox")){return i.textWithImages}if(e.querySelector(".video-container")){return i.video}if(e.querySelector(".bangumi-container")){return i.bangumi}if(e.querySelector(".article-container")){return i.column}if(e.querySelector(".music-container")){return i.audio}if(e.querySelector(".h5share-container")){return i.share}if(e.querySelector(".vc-ctnr")){return i.miniVideo}return i.text};class r extends EventTarget{constructor(){super(...arguments);this.watching=false;this.cards=[]}addEventListener(e,t,i){super.addEventListener(e,t,i)}removeEventListener(e,t,i){super.removeEventListener(e,t,i)}async addCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){if(e.querySelector(".skeleton")!==null){const t=Observer.childList(e,()=>{if(e.querySelector(".skeleton")===null){t.stop();this.addCard(e)}})}else{const t=await this.parseCard(e);this.cards.push(t);this.cards.sort((e,t)=>{if(e.id===t.id){return 0}return e.id>t.id?-1:1});const i=new CustomEvent("addCard",{detail:t});this.dispatchEvent(i)}}}async removeCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){const t=(await this.parseCard(e)).id;const i=this.cards.findIndex(e=>e.id===t);const n=this.cards[i];this.cards.splice(i,1);const r=new CustomEvent("removeCard",{detail:n});this.dispatchEvent(r)}}async parseCard(e){const t=async t=>{const i=await SpinQuery.condition(()=>e.querySelector(t),e=>e!==null);if(i===null){console.warn(e,t);return""}const n=i.innerText.trim();return n};const r=async t=>{if(t===i.bangumi){return""}const n=await SpinQuery.condition(()=>e,e=>Boolean(e.__vue__));if(n===null){console.warn(n);return""}if(t===i.repost){const e=n.__vue__.originCardData.pureText;return n.__vue__.card.item.content+"\n"+e||""}return n.__vue__.originCardData.pureText||""};const a=async e=>{const i=parseInt(await t(e));if(isNaN(i)){return 0}return i};const s={id:e.getAttribute("data-did"),username:await t(".main-content .user-name"),text:"",reposts:await a(".button-bar .single-button:nth-child(1) .text-offset"),comments:await a(".button-bar .single-button:nth-child(2) .text-offset"),likes:await a(".button-bar .single-button:nth-child(3) .text-offset"),element:e,type:n(e),async getText(){const e=await r(this.type);this.text=e;return e}};await s.getText();e.setAttribute("data-type",s.type.id.toString());return s}async startWatching(){const e=await SpinQuery.select(".card-list .content");if(!e){return false}if(this.watching){return true}this.watching=true;const t=[...e.querySelectorAll(".content>.card")];t.forEach(e=>this.addCard(e));Observer.childList(e,e=>{e.forEach(e=>{e.addedNodes.forEach(e=>this.addCard(e));e.removedNodes.forEach(e=>this.removeCard(e))})});return true}}const a=new r;const s=async(e="video")=>{if(!getUID()){return[]}const t=await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=${e==="video"?8:512}`);if(t.code!==0){throw new Error(t.message)}if(e==="video"){return t.data.cards.filter(e=>{return e.desc.orig_dy_id===0}).map(e=>{const t=JSON.parse(e.card);const i=_.get(e,"display.topic_info.topic_details",[]).map(e=>{return{id:e.topic_id,name:e.topic_name}});return{id:e.desc.dynamic_id_str,aid:t.aid,title:t.title,upID:e.desc.user_profile.info.uid,upName:e.desc.user_profile.info.uname,upFaceUrl:e.desc.user_profile.info.face,coverUrl:t.pic,description:t.desc,timestamp:e.timestamp,time:new Date(e.timestamp*1e3),topics:i,dynamic:t.dynamic,like:formatCount(e.desc.like),duration:t.duration,durationText:formatDuration(t.duration,0),playCount:formatCount(t.stat.view),danmakuCount:formatCount(t.stat.danmaku),watchlater:store.state.watchlaterList.includes(t.aid)}})}else if(e==="bangumi"){return t.data.cards.map(e=>{const t=JSON.parse(e.card);return{id:e.desc.dynamic_id_str,aid:t.aid,epID:t.episode_id,title:t.new_desc,upName:t.apiSeasonInfo.title,upFaceUrl:t.apiSeasonInfo.cover,coverUrl:t.cover,description:"",timestamp:e.timestamp,time:new Date(e.timestamp*1e3),like:formatCount(e.desc.like),durationText:"",playCount:formatCount(t.play_count),danmakuCount:formatCount(t.bullet_count),watchlater:false}})}else{return[]}};return{export:{feedsCardsManager:a,feedsCardTypes:i,getVideoFeeds:s}}}})();