恢复原来的翻页评论区,仅此而已
当前为
// ==UserScript==
// @name Bilibili 翻页评论区
// @namespace MotooriKashin
// @version 1.0.5
// @description 恢复原来的翻页评论区,仅此而已
// @author MotooriKashin
// @icon https://static.hdslb.com/images/favicon.ico
// @match *://*.bilibili.com/*
// @grant none
// @run-at document-body
// @license MIT
// ==/UserScript==
(function () {
let load = false; // 是否载入
const arr = []; // 接口暂存
Object.defineProperty(window, "bbComment", {
set: v => {
if (!load) {
// 压栈
arr.unshift(v);
}
},
get: () => {
if (load) {
// 出栈
return arr[0];
}
return class { // 等待载入
constructor() {
setTimeout(() => new window.bbComment(...arguments), 100);
}
on() { }
}
}
});
loadScript("//static.hdslb.com/phoenix/dist/js/comment.min.js").then(() => {
load = true;
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = "//static.hdslb.com/phoenix/dist/css/comment.min.css";
document.head.appendChild(link);
});
function loadScript(src, onload) {
return new Promise((r, j) => {
const script = document.createElement("script");
script.type = "text/javascript";
script.src = src;
script.addEventListener("load", () => {
script.remove();
onload && onload();
r(true);
});
script.addEventListener('error', () => {
script.remove();
j();
});
document.body.appendChild(script);
});
}
window.addEventListener("load",()=>{
document.querySelectorAll("style").forEach(d=>{
d.textContent && d.textContent.includes(".bb-comment") && d.remove();
});
});
})();