您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
无
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/439903/1018826/%E7%AE%80%E5%8D%95%E5%B0%81%E8%A3%85%E4%B8%80%E4%BA%9B%E4%BF%A1%E6%81%AF.js
// ==UserScript== // @name 简单封装一些信息 // @version 1.0.3 // @description 无 // @author Pronax // ==/UserScript== const ROOM_INFO_API = { ROOM_PLAY_INFO: undefined, ROOM_USER_INFO: undefined, getRid: async function () { if (!this.ROOM_PLAY_INFO) { await this.fetchPlayInfo(this.getTempRid()); } return this.ROOM_PLAY_INFO.room_id; }, getUid: async function () { if (!this.ROOM_PLAY_INFO) { await this.fetchPlayInfo(this.getTempRid()); } return this.ROOM_PLAY_INFO.uid; }, getDanmuLength: async function () { if (!this.ROOM_USER_INFO) { await this.fetchUserInfo(this.getTempRid()); } return this.ROOM_USER_INFO.property.danmu.length; }, getTempRid: function () { switch (true) { case location.href.match(/live.bilibili.com(\/blanc)?\/(\d+)/) != null: return location.href.match(/live.bilibili.com(\/blanc)?\/(\d+)/)[2]; case typeof (__initialState) != 'undefined': return __initialState["live-non-revenue-player"][0].defaultRoomId; default: alert("无法获得RID,请反馈给插件开发者"); } }, fetchPlayInfo: async function (rid) { return new Promise((r, j) => { fetch(`https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo?room_id=${rid}`, { credentials: 'include', }) .then(r => r.json()) .then(json => { this.ROOM_PLAY_INFO = json.data; r(); }); }); }, fetchUserInfo: async function (rid) { return new Promise((r, j) => { fetch(`https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByUser?room_id=${rid}`, { credentials: 'include', }) .then(r => r.json()) .then(json => { this.ROOM_USER_INFO = json.data; r(); }); }); } }