B-HTML5-Video

获取视频的flv地址

اعتبارا من 21-01-2022. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        B-HTML5-Video
// @version     0.2.5
// @description 获取视频的flv地址
// @author      zwb
// @license     CC
// @match       https://www.bilibili.com/video/BV*
// @match       https://www.bilibili.com/video/av*
// @run-at      document-idle
// @connect     bilibili.com
// @grant       unsafeWindow
// @grant       GM_xmlhttpRequest
// @namespace   https://greatest.deepsurf.us/zh-CN/users/135090
// ==/UserScript==
setTimeout(function(){
    var infobar=document.querySelector("#v_desc");
    var jsontag =document.createElement("a");
    var that=unsafeWindow;
    var vdata=that.__INITIAL_STATE__.videoData;
    var jsonlink="https://api.bilibili.com/x/player/playurl?otype=json&qn=120&fourk=1&cid="+vdata.cid+"&avid="+vdata.aid;
    var b_p=that.__INITIAL_STATE__.p-1;
    if (vdata.videos>1 && vdata.pages.length>1){
        jsonlink="https://api.bilibili.com/x/player/playurl?otype=json&qn=120&fourk=1&cid="+vdata.pages[b_p].cid+"&avid="+vdata.aid;
    }
    var response;
    GM_xmlhttpRequest({
        url: jsonlink,
        method: "GET",
        onload: function(res) {
            try {
                response = JSON.parse(res.responseText);
            } catch (e) {
                response = false;
            }
            var data=false;
            if (response){
                data = response.data;
            }else{
                console.log("data false");
            }
            if (data) {
                if (data.accept_quality[0]>=data.quality){
                    jsontag.href=data.durl[0].url;
                    jsontag.innerText=data.accept_description[0];
                }
            } else {
                jsontag.href=jsonlink;
                console.log("get false");
            }
        }
    });
    jsontag.style.display.margin="1em 1em";
    jsontag.style.display.color="#23ade5";
    jsontag.target="_self";
    infobar.append(jsontag,infobar.lastChild);
},2000);