Greasy Fork

Greasy Fork is available in English.

b站显示楼层(lchzh ver.)

网页端视频显示评论区楼层

目前为 2022-05-11 提交的版本。查看 最新版本

// ==UserScript==
// @name         b站显示楼层(lchzh ver.)
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  网页端视频显示评论区楼层
// @author       lchzh3473
// @match        *://*.bilibili.com/video/*
// @icon         https://app.bilibili.com/favicon.ico
// @grant        none
// ==/UserScript==

(function() {
	'use strict';
	const mname = ".reply-wrap:not(.lchzhrel)";
	setInterval(() => {
		if (document.querySelector(mname)) {
			for (const i of document.querySelectorAll(mname)) {
				i.classList.add("lchzhrel");
				const xhr = new XMLHttpRequest();
				xhr.open("get", `//api.bilibili.com/x/v2/reply/detail?type=1&oid=${window.aid}&root=${i.attributes["data-id"].value}`);
				xhr.responseType = "json";
				xhr.withCredentials = true;
				xhr.send();
				xhr.onload = () => {
					const data = xhr.response.data;
					console.log(i);
					const qwq = i.querySelector(".info");
					const qwqwq = document.createElement("span");
					qwqwq.innerHTML = `#${data.root.floor} `;
					qwq.insertBefore(qwqwq, qwq.children[0]);
					console.log(data.root.floor);
				}
			}
		}
	}, 500);
})();