B站直播间同接数显示
当前为
// ==UserScript==
// @name BiiOnlineHook
// @description B站直播间同接数显示
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author jeffz615
// @match *://live.bilibili.com/*
// @icon https://live.bilibili.com/favicon.ico
// @sandbox MAIN_WORLD
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function hook_wrapper() {
let g_rank_count = 0;
let g_online_count = 0;
function on_online_rank_count(obj) {
const rank_count = obj.data.count;
const online_count = obj.data.online_count;
let flag = false;
if (rank_count && rank_count !== g_rank_count) {
g_rank_count = rank_count;
flag = true;
}
if (online_count && online_count !== g_online_count) {
g_online_count = online_count;
flag = true;
}
if (flag) {
const shower = document.querySelector("#rank-list-ctnr-box > div.tabs > ul > li.item.live-skin-normal-text.dp-i-block.live-skin-separate-border.border-box.t-center.pointer.active")
shower.innerText = '高能用户(' + g_rank_count + '/' + g_online_count + ')';
}
}
const cb_map = {
"ONLINE_RANK_COUNT": on_online_rank_count,
};
Array.prototype.push = new Proxy(Array.prototype.push, {
apply(target, thisArg, argArray) {
try {
if (argArray && argArray.length > 0) {
for (let i = 0; i < argArray.length; i++) {
if (argArray[i] && argArray[i].cmd) {
if (cb_map[argArray[i].cmd]) {
cb_map[argArray[i].cmd](argArray[i]);
}
} else {
break;
}
}
}
} catch (e) {
console.error(e);
}
return Reflect.apply(target, thisArg, argArray);
}
});
}
hook_wrapper();
/*
let hookScript = document.createElement('script');
hookScript.textContent = '(' + hook_wrapper + ')()';
(document.head||document.documentElement).appendChild(hookScript);
hookScript.parentNode.removeChild(hookScript);
*/
})();