Greasy Fork

Greasy Fork is available in English.

B站视频下载1

B站视频下载

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/407226/827422/B%E7%AB%99%E8%A7%86%E9%A2%91%E4%B8%8B%E8%BD%BD1.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

'use strict';
    var localurl = location.href;
    var aid='',cid=''
    // bilibili
    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }
 function active(){
        if(localurl.search('bilibili')>=0 && document.querySelectorAll('.download').length==0 && localurl.search('message')==-1){bilibili();video();}
        else if(localurl.search('baidu')>=0){baidu()}
        else if(localurl.search('message.bilibili')>=0){}
        else{video()}
    }
    active();
    function bilibili(){
        var aid,cid
        function geturl(){
            var data = __INITIAL_STATE__.videoData||false
            if(data){
            aid = data.aid;
            if(typeof __INITIAL_STATE__.cidMap[aid]!== 'undefined')
                {cid = __INITIAL_STATE__.cidMap[aid].cid}
                else{
                    cid = data.cid;
                }

            console.log('aid:',aid,'cid:',cid)
            var url = 'https://www.xbeibeix.com/api/bilibiliapi.php?url=https://www.bilibili.com/&aid='+aid+'&cid='+cid;
            GM_xmlhttpRequest({url:url,method:'get',onload:function(res){
                var result = JSON.parse(res.responseText);
                $('#dltext').remove();var abtn = '<span id="dltext"><a style="background: red;color: white; padding: 5px;" target="_blank" href="'+result.url+'">'+result.hd+'</a></span>';$('#download').append(abtn);
            }})
        }else{setTimeout(geturl,500)}}
        function addbtn(){
            $('#download').remove();
            var ele1 =  $('div.ops').children()[0].innerText;
            if(ele1!=='--'){$('div#arc_toolbar_report').before('<div id="download" style="padding:5px;">下载地址:<span id="dltext" style="color:red;">正在获取下载地址</span></div>');geturl();}else{ setTimeout(addbtn,500)}
        }
        function addbagumi(){
            try{
            $('#download').remove();
            var txt = $('.coin-info').children()[1].innerText;
            if(txt!=='--'){$('.media-wrapper').before('<div id="download" style="padding:5px;">下载地址:<span id="dltext" style="color:red;">暂不支持该类视频!</span></div>')}
            else{setTimeout(addbagumi,500)}}catch(e){}
        }
        function isbangumi(){if(localurl.search('bangumi')!==-1){return true}else{return false}};
        function isvideo(){if(localurl.search('video')!==-1){return true}else{return false}};
        if(isbangumi()){addbagumi();}
        if(isvideo()){addbtn();}
        function refresh(){
        if(localurl!==location.href){
            localurl=location.href;
            if(isbangumi()){addbagumi();}
            if(isvideo()){
                addbtn();
            }
        }
        }
        setInterval(refresh,500);
    }