B-HTML5-Video

获取视频的flv地址

当前为 2022-01-21 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

您需要先安装一款用户样式管理器扩展,比如 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://greasyfork.org/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);