Bilibili-Evolved/min/bvid-convert.min.js
2020-08-22 11:35:07 +08:00

1 line
1.1 KiB
JavaScript

(()=>{return(i,e)=>{const n=["https://www.bilibili.com/video/","https://www.bilibili.com/bangumi/"].some(i=>document.URL.startsWith(i));if(i.preferAvUrl&&document.URL.startsWith("https://www.bilibili.com/video/")){SpinQuery.select(()=>unsafeWindow.aid).then(i=>{if(!i){return}const e=document.URL.replace(/\/(video|bangumi)\/(BV[\w]+)/i,(e,n)=>{return`/${n}/av${i}`});if(document.URL!==e){history.replaceState({},document.title,e)}})}return{widget:{content:`<div class="bvid-convert"></div>`,condition:async()=>{if(n){return Boolean(await SpinQuery.select(()=>unsafeWindow.aid||unsafeWindow.bvid))}else{return false}},success:()=>{e.applyStyle("bvidConvertStyle");const i=async()=>{const i=dq(".bvid-convert");const e=await(async()=>{const i=await SpinQuery.select(".av-link,.bv-link,.bvid-link");if(unsafeWindow.bvid){return unsafeWindow.bvid}return i?i.innerHTML:"未找到BV号"})();i.innerHTML=`\n<div class="bvid-convert-item">av${unsafeWindow.aid}</div>\n<div class="bvid-convert-item">${e}</div>\n`};if(document.URL.startsWith("https://www.bilibili.com/bangumi/")){Observer.videoChange(i)}else{i()}}}}}})();