B-HTML5-Live

Fork from https://greasyfork.org/users/24167

目前為 2022-01-10 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        B-HTML5-Live
// @version     0.9.5
// @description Fork from https://greasyfork.org/users/24167
// @author      esterTion-28135
// @match      https://live.bilibili.com/blanc/*
// @match      https://live.bilibili.com/*
// @exclude    https://live.bilibili.com/
// @exclude    https://live.bilibili.com/*/*
// @exclude    https://live.bilibili.com/h5/*
// @run-at      document-idle
// @connect   bilibili.com
// @grant       unsafeWindow
// @license     no-license
// @grant       GM_xmlhttpRequest
// @namespace https://greasyfork.org/zh-CN/users/135090
// ==/UserScript==
setTimeout(function(){
    var room_id=(typeof __NEPTUNE_IS_MY_WAIFU__ == "undefined")?unsafeWindow.__statisObserverConfig.pvConfig.selfDefMsg.room_id:unsafeWindow.__NEPTUNE_IS_MY_WAIFU__.baseInfoRes.data.room_id;
    var infobar=document.querySelector(".room-info-ctnr.dp-i-block");
    var jsontag =document.createElement("a");
    var jsonlink="https://api.live.bilibili.com/room/v1/Room/playUrl?platform=h5&otype=json&quality=4&cid="+room_id;
    var response;
    GM_xmlhttpRequest({
        url: jsonlink,
        method: "GET",
        onload: function(res) {
            console.info('BilibiliHLS', 'NetworkResponse', res, JSON.parse(res.response));
            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) {
                jsontag.href=data.durl[0].url;
            } else {
                jsontag.href=jsonlink;
                console.log("get false");
            }
        }
    });
    jsontag.style.display.margin="2px 2px";
    jsontag.innerText=document.title;
    jsontag.target="_self";
    infobar.insertBefore(jsontag,infobar.lastChild);
},1000);
var sidead = document.querySelector("#sections-vm");
var imgnode = document.createElement("span");
imgnode.setAttribute("id", "user_cover");
imgnode.setAttribute("style", "display:block;margin:2px auto;");
if (typeof __NEPTUNE_IS_MY_WAIFU__ =="undefined"){
    var apiurl="https://api.live.bilibili.com/room/v1/Room/get_info?device=phone&platform=ios&scale=3&build=10000&room_id=";
    var sn=location.pathname.lastIndexOf("/")+1;
    var roomid=location.pathname.substring(sn);
    var webapi = apiurl + roomid;
    var response;
    GM_xmlhttpRequest({
        url: webapi,
        method: "GET",
        onload: function(res) {
            console.info('BilibiliCover', 'NetworkResponse', res, JSON.parse(res.response));
            try {
                response = JSON.parse(res.responseText);
            } catch (e) {
                response = false;
            }
            var data;
            if (response){
                data = response.data;
            }else{
                data =false;
                console.log("data false");
            }
            if (data) {
                var cover = data.user_cover;
                var i=cover.indexOf(":")+1;
                cover=cover.substring(i);
                var coverhtml= "<hr /><a href=\""+cover+"\" target=_blank >查看封面</a><hr />";
                imgnode.innerHTML=coverhtml;
                sidead.insertBefore(imgnode,sidead.firstChild);
            } else {
                console.log("get false");
            }
        }
    });
} else {
    var data=unsafeWindow.__NEPTUNE_IS_MY_WAIFU__.baseInfoRes.data;
    if (data){
        var cover = data.user_cover;
        var i=cover.indexOf(":")+1;
        cover=cover.substring(i);
        var coverhtml= "<hr /><a href=\""+cover+"\" target=_blank >查看封面</a><hr />";
        imgnode.innerHTML=coverhtml;
        sidead.insertBefore(imgnode,sidead.firstChild);
    } else {
        console.log("get false");
    }
}