diff --git a/min/custom-navbar-user-info.min.js b/min/custom-navbar-user-info.min.js index 5abed0595d..b3f17c5952 100644 --- a/min/custom-navbar-user-info.min.js +++ b/min/custom-navbar-user-info.min.js @@ -1 +1 @@ -(()=>(e,i)=>{function n(e,i,n){if(i in e){Object.defineProperty(e,i,{value:n,enumerable:true,configurable:true,writable:true})}else{e[i]=n}return e}const{NavbarComponent:t}=i.import("custom-navbar-component");class s extends t{constructor(){super();n(this,"userInfo",{mid:getUID(),isLogin:Boolean(getUID())});this.boundingWidth=240;this.noPadding=true;this.href="https://space.bilibili.com";this.html=`\n
\n\n\n
\n`;this.popupHtml=`
`;this.requestedPopup=true;this.init()}get name(){return"userInfo"}async init(){const e=await SpinQuery.select(".custom-navbar .user-info-panel");const i=await SpinQuery.select(".custom-navbar .user-face-container .user-face");const n=await Ajax.getJsonWithCredentials("https://api.bilibili.com/x/web-interface/nav");const t=await Ajax.getJsonWithCredentials("https://api.bilibili.com/x/web-interface/nav/stat");Object.assign(this.userInfo,n.data);Object.assign(this.userInfo,t.data);const s=new Vue({template:`\n
\n
\n{{uname}}\n{{userType}}\n
\n
\n {{privileges.bCoin.received ? '已领取B币' : '领取B币'}}\n
\n
\n {{privileges.coupons.received ? '已领取优惠券' : '领取优惠券'}}\n
\n
\n
\n\n\n\n{{level_info.current_exp}} / {{level_info.next_exp}}\n
\n
\n
\n
\n\n
\n\n
\n\n\n 个人中心\n\n\n\n 投稿管理\n\n\n\n B币钱包\n\n\n\n 直播中心\n\n\n\n 订单中心\n\n\n\n 我的课程\n\n
\n 退出登录\n
\n
\n
\n

欢迎来到 bilibili

\n\n\n
\n
\n`,data:{...this.userInfo,privileges:{bCoin:{received:false,expire:""},coupons:{received:false,expire:""}}},filters:{count(e){return formatCount(e)}},computed:{userType(){if(!this.isLogin){return"未登录"}if(this.level_info.current_level===0){return"注册会员"}if(this.vipStatus===1){if(this.vipType===1){return this.vip_theme_type?"小会员":"大会员"}else if(this.vipType===2){return this.vip_theme_type?"年度小会员":"年度大会员"}}return"正式会员"},levelProgressStyle(){const e=(this.level_info.current_exp-this.level_info.current_min)/(this.level_info.next_exp-this.level_info.current_min);return{transform:`scaleX(${e})`}}},methods:{async privilegeReceive(e){const i={1:"bCoin",2:"coupons"};if(this.privileges[i[e]].received){return}this.privileges[i[e]].received=true;const n=getCsrf();const t=await(await fetch("https://api.bilibili.com/x/vip/privilege/receive",{credentials:"include",headers:{"content-type":"application/x-www-form-urlencoded"},body:`type=${e}&csrf=${n}`,method:"POST"})).json();console.log(t);if(t.code===0){if(i[e]==="bCoin"){this.wallet.bcoin_balance+=5}}else if(t.code===69801){return}else{this.privileges[i[e]].received=false;logError(t.message)}},async logout(){const e=await Ajax.postTextWithCredentials("https://passport.bilibili.com/login/exit/v2",formData({biliCSRF:getCsrf()}));const i=_.get(e,"data.redirectUrl","");if(i){window.location.assign(i)}}}});s.$mount(e);if(this.userInfo.isLogin){const e=this.userInfo.face.replace("http","https");const n="//static.hdslb.com/images/member/noface.gif";if(!e.includes(n)){const n=68;i.setAttribute("srcset",getDpiSourceSet(e,n))}else{i.setAttribute("src",n)}if(this.userInfo.pendant.image){const e=await SpinQuery.select(".custom-navbar .user-face-container .user-pendant");const i=this.userInfo.pendant.image.replace("http","https");const n=116;e.setAttribute("srcset",getDpiSourceSet(i,n,"png"))}if(this.userInfo.vipType===2){const e=await Ajax.getJsonWithCredentials("https://api.bilibili.com/x/vip/privilege/my");if(e.code===0){const i=e.data.list.find((e=>e.type===1));s.privileges.bCoin.received=i.state===1;s.privileges.bCoin.expire=new Date(i.expire_time*1e3).toLocaleDateString();const n=e.data.list.find((e=>e.type===2));s.privileges.coupons.received=n.state===1;s.privileges.coupons.expire=new Date(n.expire_time*1e3).toLocaleDateString()}}}else{i.setAttribute("src","https://static.hdslb.com/images/akari.jpg")}}}return{export:{UserInfo:s}}})(); \ No newline at end of file +(()=>(e,i)=>{function n(e,i,n){if(i in e){Object.defineProperty(e,i,{value:n,enumerable:true,configurable:true,writable:true})}else{e[i]=n}return e}const{NavbarComponent:t}=i.import("custom-navbar-component");class s extends t{constructor(){super();n(this,"userInfo",{mid:getUID(),isLogin:Boolean(getUID())});this.boundingWidth=240;this.noPadding=true;this.href="https://space.bilibili.com";this.html=`\n
\n\n\n
\n`;this.popupHtml=`
`;this.requestedPopup=true;this.init()}get name(){return"userInfo"}async init(){const e=await SpinQuery.select(".custom-navbar .user-info-panel");const i=await SpinQuery.select(".custom-navbar .user-face-container .user-face");const n=await Ajax.getJsonWithCredentials("https://api.bilibili.com/x/web-interface/nav");const t=await Ajax.getJsonWithCredentials("https://api.bilibili.com/x/web-interface/nav/stat");Object.assign(this.userInfo,n.data);Object.assign(this.userInfo,t.data);const s=new Vue({template:`\n
\n
\n{{uname}}\n{{userType}}\n
\n
\n {{privileges.bCoin.received ? '已领取B币' : '领取B币'}}\n
\n
\n {{privileges.coupons.received ? '已领取优惠券' : '领取优惠券'}}\n
\n
\n
\n\n\n\n{{level_info.current_exp}} / {{level_info.next_exp}}\n
\n
\n
\n
\n\n
\n\n
\n\n\n 个人中心\n\n\n\n 投稿管理\n\n\n\n B币钱包\n\n\n\n 直播中心\n\n\n\n 订单中心\n\n\n\n 我的课程\n\n
\n 退出登录\n
\n
\n
\n

欢迎来到 bilibili

\n\n\n
\n
\n`,data:{...this.userInfo,privileges:{bCoin:{received:false,expire:""},coupons:{received:false,expire:""}}},filters:{count(e){return formatCount(e)}},computed:{userType(){if(!this.isLogin){return"未登录"}if(this.level_info.current_level===0){return"注册会员"}if(this.vipStatus===1){if(this.vipType===1){return this.vip_theme_type?"小会员":"大会员"}else if(this.vipType===2){return this.vip_theme_type?"年度小会员":"年度大会员"}}return"正式会员"},levelProgressStyle(){const e=(this.level_info.current_exp-this.level_info.current_min)/(this.level_info.next_exp-this.level_info.current_min);return{transform:`scaleX(${e})`}}},methods:{async privilegeReceive(e){const i={1:"bCoin",2:"coupons"};if(this.privileges[i[e]].received){return}this.privileges[i[e]].received=true;const n=getCsrf();const t=await(await fetch("https://api.bilibili.com/x/vip/privilege/receive",{credentials:"include",headers:{"content-type":"application/x-www-form-urlencoded"},body:`type=${e}&csrf=${n}`,method:"POST"})).json();console.log(t);if(t.code===0){if(i[e]==="bCoin"){this.wallet.bcoin_balance+=5}}else if(t.code===69801){return}else{this.privileges[i[e]].received=false;logError(t.message)}},async logout(){const e=await Ajax.postTextWithCredentials("https://passport.bilibili.com/login/exit/v2",formData({biliCSRF:getCsrf()}));const i=_.get(JSON.parse(e),"data.redirectUrl","");if(i){window.location.assign(i)}}}});s.$mount(e);if(this.userInfo.isLogin){const e=this.userInfo.face.replace("http","https");const n="//static.hdslb.com/images/member/noface.gif";if(!e.includes(n)){const n=68;i.setAttribute("srcset",getDpiSourceSet(e,n))}else{i.setAttribute("src",n)}if(this.userInfo.pendant.image){const e=await SpinQuery.select(".custom-navbar .user-face-container .user-pendant");const i=this.userInfo.pendant.image.replace("http","https");const n=116;e.setAttribute("srcset",getDpiSourceSet(i,n,"png"))}if(this.userInfo.vipType===2){const e=await Ajax.getJsonWithCredentials("https://api.bilibili.com/x/vip/privilege/my");if(e.code===0){const i=e.data.list.find((e=>e.type===1));s.privileges.bCoin.received=i.state===1;s.privileges.bCoin.expire=new Date(i.expire_time*1e3).toLocaleDateString();const n=e.data.list.find((e=>e.type===2));s.privileges.coupons.received=n.state===1;s.privileges.coupons.expire=new Date(n.expire_time*1e3).toLocaleDateString()}}}else{i.setAttribute("src","https://static.hdslb.com/images/akari.jpg")}}}return{export:{UserInfo:s}}})(); \ No newline at end of file diff --git a/src/style/custom-navbar/simple/custom-navbar-user-info.ts b/src/style/custom-navbar/simple/custom-navbar-user-info.ts index 64e8571c46..1b887c9ce8 100644 --- a/src/style/custom-navbar/simple/custom-navbar-user-info.ts +++ b/src/style/custom-navbar/simple/custom-navbar-user-info.ts @@ -237,7 +237,7 @@ export class UserInfo extends NavbarComponent { biliCSRF: getCsrf(), }) ) - const url = _.get(response, 'data.redirectUrl', '') + const url = _.get(JSON.parse(response), 'data.redirectUrl', '') if (url) { window.location.assign(url) }