// ==UserScript== // @name Bilibili 翻页评论区 // @namespace MotooriKashin // @version 2.0.0 // @description 恢复评论区翻页功能。 // @author MotooriKashin // @homepage https://github.com/MotooriKashin/Bilibili-Old // @supportURL https://github.com/MotooriKashin/Bilibili-Old/issues // @icon https://www.bilibili.com/favicon.ico // @match *://*.bilibili.com/* // @grant none // @run-at document-start // @license MIT // @downloadURL none // ==/UserScript== "use strict"; (() => { // src/runtime/lib/typeof.ts var isArray = Array.isArray; // src/runtime/element/add_element.ts 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 || document.head || document.documentElement || document).appendChild(script); }); } // src/content/comment.ts var Feedback; var loading = false; var load = false; function loadComment() { Object.defineProperty(window, "bbComment", { configurable: true, set: (v) => { if (!v.prototype._createNickNameDom) { return loadScript("//s1.hdslb.com/bfs/seed/jinkela/commentpc/comment.min.js").then(() => { Array.from(document.styleSheets).forEach((d) => { d.href && d.href.includes("comment") && (d.disabled = true); }); }); } Feedback = v; bbCommentModify(); Object.defineProperty(window, "bbComment", { configurable: true, value: Feedback }); }, get: () => { return Feedback ? Feedback : class { constructor() { if (!loading) { loadScript("//s1.hdslb.com/bfs/seed/jinkela/commentpc/comment.min.js").then(() => { Array.from(document.styleSheets).forEach((d) => { d.href && d.href.includes("comment") && (d.disabled = true); }); }); loading = true; } setTimeout(() => new window.bbComment(...arguments)); } on() { } }; } }); Object.defineProperty(window, "initComment", { configurable: true, set: (v) => true, get: () => { if (load) { let initComment2 = function(tar, init) { new Feedback(tar, init.oid, init.pageType, init.userStatus); }; var initComment = initComment2; Object.defineProperty(window, "initComment", { configurable: true, value: initComment2 }); return initComment2; } return function() { if (!loading) { loadScript(`//s1.hdslb.com/bfs/seed/jinkela/commentpc/comment.min.js`).then(() => { load = true; }); } loading = true; setTimeout(() => window.initComment(...arguments), 100); }; } }); } function bbCommentModify() { Feedback.prototype.initAbtest = function() { this.abtest = {}; this.abtest.optimize = false; if (this.jumpId || this.noPage) { this.abtest.optimize = false; } if (this.appMode === "comic") { this.abtest.optimize = false; } this._registerEvent(); this.init(); }; Feedback.prototype._renderBottomPagination = function(pageInfo) { if (this.noPage) { var isLastPage = pageInfo.count <= this.pageSize; var html = ""; if (isLastPage) { html = "没有更多了~"; } else { html = '查看更多评论'; } this.$root.find(".bottom-page").addClass("center").html(html); return; } const count = Math.ceil(pageInfo.count / pageInfo.size); if (count > 1) { this.$root.find(".header-interaction").addClass("paging-box").paging({ pageCount: count, current: pageInfo.num, backFn: (p) => { this.$root.trigger("replyPageChange", { p, isBottom: true }); this.trigger("replyPageChange", { p, isBottom: true }); this.currentPage = p; } }); this.$root.find(".bottom-page").paging({ pageCount: count, current: pageInfo.num, jump: true, smallSize: this.smallPager, backFn: (p) => { this.$root.trigger("replyPageChange", { p, isBottom: true }); this.trigger("replyPageChange", { p, isBottom: true }); this.currentPage = p; } }); } else { this.$root.find(".header-page").html(""); this.$root.find(".bottom-page").html(""); } }; Feedback.prototype._createListCon = function(item, i, pos) { const blCon = this._parentBlacklistDom(item, i, pos); const con = [ '
', '
' + this._createNickNameDom(item), this._createLevelLink(item), this._identity(item.mid, item.assist, item.member.fans_detail), this._createNameplate(item.member.nameplate) + this._createUserSailing(item) + "
", this._createMsgContent(item), this._createPerfectReply(item), '
', item.floor ? '#' + item.floor + "" : "", this._createPlatformDom(item.content.plat), '', ''.concat(this._formateTime(item.ctime), ""), item?.reply_control?.location ? `${item?.reply_control?.location || ""}` : "", "", item.lottery_id ? "" : '", item.lottery_id ? "" : '', item.lottery_id ? "" : this._createReplyBtn(item.rcount), item.lottery_id && item.mid !== this.userStatus.mid ? "" : '
    ' + (this._canSetTop(item) ? '
  • ' + (item.isUpTop ? "取消置顶" : "设为置顶") + "
  • " : "") + (this._canBlackList(item.mid) ? '
  • 加入黑名单
  • ' : "") + (this._canReport(item.mid) ? '
  • 举报
  • ' : "") + (this._canDel(item.mid) && !item.isTop ? '
  • 删除
  • ' : "") + "
", this._createLotteryContent(item.content), this._createVoteContent(item.content), this._createTags(item), "
", '
', this._createSubReplyList(item.replies, item.rcount, false, item.rpid, item.folder && item.folder.has_folded, item.reply_control), "
", '
', "
", "
" ].join(""); return item.state === this.blacklistCode ? blCon : con; }; Feedback.prototype._createSubReplyItem = function(item, i) { if (item.invisible) { return ""; } return [ '
', this._createSubReplyUserFace(item), '
', '
', this._createNickNameDom(item), this._createLevelLink(item), this._identity(item.mid, item.assist, item.member.fans_detail), this._createSubMsgContent(item), "
", "
", '
', item.floor ? '#' + item.floor + "" : "", this._createPlatformDom(item.content.plat), '', ''.concat(this._formateTime(item.ctime), ""), item?.reply_control?.location ? `${item?.reply_control?.location || ""}` : "", "", '", '', '回复', '
    ' + (this._canBlackList(item.mid) ? '
  • 加入黑名单
  • ' : "") + (this._canReport(item.mid) ? '
  • 举报
  • ' : "") + (this._canDel(item.mid) ? '
  • 删除
  • ' : "") + "
", "
", "
" ].join(""); }; } // src/tampermonkey/bb_comment.ts loadComment(); })(); // @license MIT