Greasy Fork is available in English.
(2022/05可用)bilibili哔哩哔哩网页端视频、番剧、动态显示评论区楼层与楼中楼楼层,理论兼容Bilibill Evolved
当前为
// ==UserScript==
// @name 哔哩哔哩(B站)评论区显示楼层
// @description (2022/05可用)bilibili哔哩哔哩网页端视频、番剧、动态显示评论区楼层与楼中楼楼层,理论兼容Bilibill Evolved
// @author lchzh3473 , Modify by Tinhone
// @namespace Original by lchzh3473 , Modify by Tinhone
// @license GPL-3.0
// @version 1.2.0
// @icon https://app.bilibili.com/favicon.ico
// @grant none
// @compatible firefox V70+
// @compatible edge V70+
// @compatible chrome V70+
// @match *://www.bilibili.com/video/*
// @match *://www.bilibili.com/read/cv*
// @match *://www.bilibili.com/bangumi/play/*
// @match *://t.bilibili.com/*
// @match *://space.bilibili.com/*
// @exclude *://t.bilibili.com/
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
setInterval(() => {
const qwqwqwq1=document.querySelectorAll(".reply.btn-hover:not(.b)") //排除已被 qw class包含的元素
const qwqwqwq2=document.querySelectorAll(".list-item.reply-wrap:not(.a)")//寻找相应属性的div
if (document.querySelector(".comment-m .common .b-head:not(.e)")){ //在视频页面显示共有多少楼层
const owo1=document.querySelector(".comment-m .common .b-head:not(.e)")
owo1.classList.add("e")
const xhr1=new XMLHttpRequest() //获取最新评论
xhr1.open("get",`//api.bilibili.com/x/v2/reply/main?type=1&oid=${window.aid}&mode=2`)
xhr1.responseType="json"
xhr1.withCredentials=true
xhr1.send()
xhr1.onload=()=>{
const owowowo1=xhr1.response.data.replies[0].rpid
const xhr2=new XMLHttpRequest() //获取最新评论的楼层
xhr2.open("get",`//api.bilibili.com/x/v2/reply/info?type=12&oid=1&rpid=${owowowo1}`)
xhr2.responseType="json"
xhr2.withCredentials=true
xhr2.send()
xhr2.onload=()=>{
const owowowo2=xhr2.response.data.floor
const owowo1=document.createElement("span")
const owowo2=document.createElement("span")
owowo1.innerHTML=`${owowowo2}`
owowo2.innerHTML="楼"
owowo1.setAttribute("style","margin-left: 17px;margin-right: 3px;font-size: 80%;color:#424242")
owowo2.setAttribute("style","font-size: 90%;color:#424242")
owo1.appendChild(owowo1)
owo1.appendChild(owowo2)
}
}
}
if(document.querySelector(".reply.btn-hover:not(.b)")){
for(const i1 of qwqwqwq1){ //设置 回复 按钮样式
i1.setAttribute("style","height:16px !important;padding-top:2px !important;padding-bottom:2px !important");
i1.classList.add("b");
}
}
if (document.querySelector(".list-item.reply-wrap:not(.a)")) {
for (const i2 of qwqwqwq2){ //显示 显示楼中楼 按钮,以及对应功能
var i2_1=i2.querySelector(".operation.more-operation .opera-list ul:not(.b)")
var li=document.createElement("li");
li.setAttribute("class","floor-in-floor")
li.addEventListener("click",(()=>{ //点击事件
i2.classList.add("c")
}))
li.innerHTML="楼中楼楼层"
i2_1.appendChild(li)
i2_1.classList.add("b")
}
for (const i3 of qwqwqwq2) { //显示楼层
i3.classList.add("a");
const qwq = i3.querySelector(".info");
const xhr = new XMLHttpRequest();
//xhr.open("get", `//api.bilibili.com/x/v2/reply/detail?type=12&oid=1&root=${i.attributes["data-id"].value}`); //另一个api接口,可用
xhr.open("get", `//api.bilibili.com/x/v2/reply/info?type=12&oid=1&rpid=${i3.attributes["data-id"].value}`);
xhr.responseType = "json";
xhr.withCredentials = true;
xhr.send();
xhr.onload = () => {
const data = xhr.response
const qwqwq = document.createElement("span");
qwqwq.setAttribute("style","height:16px;margin-right:14px");
qwqwq.innerHTML = `#${data.data.floor}`;
qwq.appendChild(qwqwq); //加在div info最后
}
}
}
if (document.querySelector(".list-item.reply-wrap.c .con .reply-box .reply-item.reply-wrap")){
for (const i4 of document.querySelectorAll(".list-item.reply-wrap.c")){
const i4_2=i4.querySelectorAll(".con .reply-box .reply-item.reply-wrap:not(.d)")
for (const i4_2_1 of i4_2){ //显示楼中楼楼层
const i4_2_1_1=i4_2_1.querySelector(".info")
i4_2_1.classList.add("d")
const xhr=new XMLHttpRequest()
xhr.open("get",`//api.bilibili.com/x/v2/reply/info?type=12&oid=1&rpid=${i4_2_1.attributes["data-id"].value}`)
xhr.responseType="json"
xhr.withCredentials=true
xhr.send()
xhr.onload=()=>{
const data=xhr.response
const span=document.createElement("span")
span.setAttribute("style","height:16px;margin-right:14px")
span.innerHTML=`#${data.data.floor}`
i4_2_1_1.appendChild(span)
}
}
}
}
}, 1000);
})();