这个 js 是在某个 Chrome 插件里看到的 挺有意思的 又能发弹幕又能点赞还能删记录还能根据用户最新视频操作 发上来给各位 dalao 过目一下
(() = >{
if ("www.bilibili.com" === location.hostname) {
const e = !1,
i = e = >{
const i = {};
return document.cookie.split(";").forEach(e = >{
const t = e.trim().split("=");
i[t[0]] = t[1]
}),
i[e]
};
let t = null;
const a = 5e3,
o = 300,
d = 1e5,
l = {
coin: 0,
danmaku: 0,
favorite: 0,
like: 0,
reply: 0,
share: 0,
view: 0
},
r = {},
n = ["666", "666666", "支持", "厉害厉害", "可以可以", "牛逼", "666666666"],
c = () = >{
const e = parseInt(Math.random() * n.length);
return n[e]
},
s = () = >{
return fetch(` //www.bilibili.com/video/av${t}/?inooo=sanm`,{method:"GET",credentials:"include"}).then(e=>e.text()).then(e=>{const i=e.match(/<script>window.__INITIAL_STATE__=(.+?)<\/script>/);if(i&&i[1]){const e=i[1].replace(";(function(){var s;(s=document.currentScript||document.scripts[document.scripts.length-1]).parentNode.removeChild(s);}());","");return JSON.parse(e)}return{}})},p=()=>fetch("//api.bilibili.com/x/web-interface/archive/stat?aid="+t,{credentials:"include",method:"GET",mode:"cors"}).then(e=>e.json()).then(e=>e.data),m=()=>{if(localStorage.bilibilihelperliked+""==""+t&&!e)return;const o=i("bili_jct");o&&(l.like>a||fetch("//api.bilibili.com/x/web-interface/archive/like",{headers:{"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},body:`aid=${t}&like=1&csrf=${o}`,credentials:"include",method:"POST",mode:"cors"}).then(()=>{localStorage.bilibilihelperliked=""+t}))},h=()=>{const a=(new Date).getDate();if(localStorage.bilibilihelperdanmaku+""==""+t+a&&!e)return;const o=i("bili_jct");if(!o)return;const d=r.videoData.duration,l=parseInt(Math.random()*d*1e3),n=`type=1&oid=${r.videoData.cid}&msg=${c()}&aid=${t}&progress=${l}&color=16777215&fontsize=25&pool=0&mode=1&rnd=${1e3*Date.now()}&plat=1&csrf=${o}`;fetch("//api.bilibili.com/x/v2/dm/post",{headers:{"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},body:n,credentials:"include",method:"POST",mode:"cors"}).then(()=>{localStorage.bilibilihelperdanmaku=""+t+a})},b=()=>{const a=(new Date).getDate();if(localStorage.bilibilihelperplay+""==""+t+a&&!e)return;const o=r.videoData.duration-1,d=Date.now(),l=parseInt((d+1e3)/1e3),n=r.videoData.cid,c=!!document.getElementById("playerWrap")?"HTML5PlayerNew211bf0ca":"HTML5Player+c31db083",s=i("DedeUserID")||"",p=i("bili_jct")||"",m=`//data.bilibili.com/v/flashplay/h5_player_op?pname=1&mid=${s}&statue=3&playmethod=2&avid=${t}&eventparam=&progress=0&displayid=${d}&eventid=play_screen&trackerid=&cid=${n}&fver=${c}&seasonid=&epid=&videotype=1&fid=web_player`,h=`//data.bilibili.com/v/flashplay/h5_player_op?pname=1&mid=${s}&statue=3&playmethod=2&avid=${t}&eventparam=&progress=${o}&displayid=${d}&eventid=end&trackerid=&cid=${n}&fver=${c}&seasonid=&epid=&videotype=1&fid=web_player`,b=`//data.bilibili.com/v/flashplay/h5_player_op?pname=1&mid=${s}&statue=3&playmethod=2&avid=${t}&eventparam=&progress=${o}&displayid=${d}&eventid=end_recommend_show&trackerid=&cid=${n}&fver=${c}&seasonid=&epid=&videotype=1&fid=web_player`;fetch(`//data.bilibili.com/v/flashplay/h5_player_op?pname=1&mid=${s}&statue=3&playmethod=2&avid=${t}&eventparam=&progress=0&displayid=${d}&eventid=enter&trackerid=&cid=${n}&fver=${c}&seasonid=&epid=&videotype=1&fid=web_player`,{credentials:"include",method:"GET",mode:"cors"}).finally(()=>{setTimeout(()=>{fetch(m,{credentials:"include",method:"GET",mode:"cors"}).finally(()=>{let e=!1;const i=d=>{if(e)return;let r=d||0;if(r>o/1.9&&(localStorage.bilibilihelperplay=""+t+a),r>=o)return;fetch("//api.bilibili.com/x/report/web/heartbeat",{headers:{"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},body:`aid=${t}&cid=${n}&mid=${s}&csrf=${p}&played_time=${r}&realtime=${r}&start_ts=${l}&type=3&dt=2&play_type=${0===r?1:0}`,credentials:"include",method:"POST",mode:"cors"}).finally(()=>{setTimeout(()=>{p&&fetch("//api.bilibili.com/x/v2/history/del",{body:`aid=${t}&jsonp=jsonp&csrf=${p}`,headers:{"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},credentials:"include",method:"POST",mode:"cors"}).then(()=>{})},500)}),setTimeout(()=>{i(r+15)},15e3)};i(),setTimeout(()=>{e=!0,fetch(h,{credentials:"include",method:"GET",mode:"cors"}).finally(()=>{fetch("//api.bilibili.com/x/report/web/heartbeat",{headers:{"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},body:`aid=${t}&cid=${n}&mid=${s}&csrf=${p}&played_time=-1&realtime=${o}&start_ts=${l}&type=3&dt=2&play_type=4`,credentials:"include",method:"POST",mode:"cors"}).finally(()=>{fetch(b,{credentials:"include",method:"GET",mode:"cors"}).finally(()=>{}),setTimeout(()=>{p&&fetch("//api.bilibili.com/x/v2/history/del",{body:`aid=${t}&jsonp=jsonp&csrf=${p}`,headers:{"content-type":"application/x-www-form-urlencoded; charset=UTF-8"},credentials:"include",method:"POST",mode:"cors"}).then(()=>{})},500)})})},1e3*o)})},2e3)})};(()=>fetch("//space.bilibili.com/ajax/top/showTop?mid=用户 id&guest=0",{credentials:"include",method:"GET",mode:"cors"}).then(e=>e.json()).then(e=>(e.data&&e.data.aid&&(t=e.data.aid),t)))().then(e=>{e&&p().then(e=>(Object.assign(l,e),s())).then(e=>{Object.assign(r,e),l.view<d&&b(),l.like<a&&m(),l.danmaku<o&&h()})})}})();
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.