天天动画片 > 八卦谈 > 怎么用Gif做头像?让你的头像动起来!

怎么用Gif做头像?让你的头像动起来!

八卦谈 佚名 2023-05-01 21:17:49

此方法已和谐

首先准备一个180*180大小的GIF图片。
然后通过 https://www.upyun.com/webp 上传保存好webp格式。
然后复制下列代码

javascript:void (()=>{var a=document.createElement("input");a.type="file";a.onchange=function(){if(a.files.length>0){var b=new FormData();b.append("dopost","save");b.append("Displayrank","10000");b.append("face",a.files[0]);var c=new XMLHttpRequest();c.withCredentials=!!1;c.open("POST","https://api.bilibili.com/x/member/web/face/update?csrf="+document.cookie.match(/bili_jct=(.+?);/)[1]);c.onload=function(){var d=c.response;try{d=JSON.parse(d);switch(d.code){case 0:alert("更新成功,刷新页面即可");break;case 40012:alert("头像格式错误");break;case 40013:alert("头像大小不能超过2M");break;default:alert("未知返回"+c.response);console.error(c.response, c);break}}catch(e){console.error(e, c, d);alert("解析返回数据时出现错误,具体看console")}};c.onerror=function(e){console.error(e,c);alert("请求出现错误,具体看console");};c.send(b)}else{alert("请选择一个文件")}};a.click();})()

然后打开B站更换头像的网页,按下F12打开审查元素,点击Console

将上面的代码复制进去后按下回车,之后选择你所保存的webp文件

提示成功后刷新网页即可

原作者:https://www.caixiaojing.com/Tech-Otakus/dynamicAvatar.html

本文标题:怎么用Gif做头像?让你的头像动起来! - 八卦谈
本文地址:www.ttdhp.com/article/29640.html

天天动画片声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
扫码关注我们