bilibili native mp4 + converted ass download

在bilibili视频的播放数统计旁边添加原生MP4、转换后的ASS的下载链接。

As of 2017-04-10. See the latest version.

Author
qli5
Ratings
0 0 0
Version
0.2
Created
2017-03-03
Updated
2017-04-10
License
Mozilla Public License 2.0
Applies to

在bilibili视频的播放数统计旁边添加原生MP4、转换后的ASS的下载链接。要求使用B站的HTML5播放器。

完全使用B站API,不借助任何第三方缓存,不需要任何额外权限。所以不用担心隐私,也能充分利用最快的B站视频CDN源。

不安装的话,新建一个书签,书签地址粘贴下面的代码,想用的时候点一下也可以使用。安装的话,能让作者看到数字增长,然后暗爽:)

原理是挟持jQuery,发现视频网址就撸下来。B站API居然就是没加密的JSON,请大家不要强撸灰飞烟灭,且行且珍惜。

引用了2014+, 田生的ASS转换脚本。感谢大神。

===书签栏简易代码===
javascript:function GM_xmlhttpRequest(e){$.ajax({method:e.method,url:e.url,dataType:'text',success:function(t){e.onload({responseText:t})}})}var script=document.createElement('script');script.setAttribute('src','https://greasyfork.org/scripts/2231-bilibili-ass-danmaku-downloader/code/bilibili ASS Danmaku Downloader.user.js'),document.body.appendChild(script);var t=setInterval(function(){function e(){if(document.querySelector('div.bilibili-player-video-btn.bilibili-player-video-btn-quality > div > ul > li:nth-child(2)')){var e=$.ajax;$.ajax=function(t,o){try{if(-1!=t.url.search('interface.bilibili.com')){var c=t.success;c({});var r=t.url.match(/cid=\d*/)[0].slice(4);fetchDanmaku(r,function(e){var t=generateASS(setPosition(e),{title:name,ori:location.href}),i=new Blob(['\ufeff'+t],{type:'application/octet-stream'});n.href=window.URL.createObjectURL(i)}),t.success=function(e){i.href=e.durl[0].url,n.download=i.href.match(/\d(\d|-|hd)*(?=\.mp4)/)[0]+'.ass'},$.ajax=e}}catch(l){}e(t,o)},document.querySelector('div.bilibili-player-video-btn.bilibili-player-video-btn-quality > div > ul > li:nth-child(2)').click()}}if(initFont){clearInterval(t),init=function(){},initFont();var i=document.createElement('a'),n=document.createElement('a');i.textContent='MP4',n.textContent='ASS',e(),i.onmouseenter=n.onmouseenter=function(){this.href||e()},document.querySelector('div.v-title > h1').appendChild(document.createTextNode(' ')),document.querySelector('div.v-title-info').appendChild(i),document.querySelector('div.v-title-info').appendChild(document.createTextNode(' ')),document.querySelector('div.v-title-info').appendChild(n)}},600);