Fork from https://greasyfork.org/users/24167
目前為
// ==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");
}
}