您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
ニコニコ動画の最大同時コメント表示数を変更できるUserScriptです。デフォルトでは標準と同じ40になっているので、GM_valueのSlotCountを変更してください。※注意: 増やせば増やすほどメモリを食います(実際にそれだけのコメントがなくても)
当前为
// ==UserScript== // @name niconico slot count changer // @namespace rinsuki.net // @match https://www.nicovideo.jp/watch/* // @version 1.0 // @grant GM_getValue // @grant GM_setValue // @author rinsuki // @description ニコニコ動画の最大同時コメント表示数を変更できるUserScriptです。デフォルトでは標準と同じ40になっているので、GM_valueのSlotCountを変更してください。※注意: 増やせば増やすほどメモリを食います(実際にそれだけのコメントがなくても) // ==/UserScript== (() => { const loadedSlotCount = GM_getValue("SlotCount") const EXPECT_SLOT_COUNT = Math.min(100000, typeof loadedSlotCount === "number" && Number.isSafeInteger(loadedSlotCount) && loadedSlotCount > 0 ? loadedSlotCount : 40) GM_setValue("SlotCount", EXPECT_SLOT_COUNT) function getReactInternalInstance(dom) { for (const key in dom) { if (key.startsWith("__reactInternalInstance$")) return dom[key] } } const observer = new unsafeWindow.MutationObserver(mutations => { for (const mutation of mutations) { if (mutation.target.id === "CommentRenderer") { const commentRenderer = mutation.target const commentRendererInstance = getReactInternalInstance(commentRenderer).return.stateNode.renderer console.log("comment renderer detected", commentRendererInstance) /** @type {Function} */ const orig = commentRendererInstance.__proto__.registerLayerProcessorEvents commentRendererInstance.__proto__.registerLayerProcessorEvents = function(layer) { console.log("registerLayerProcessorEvents", layer) /** @type {{_stagingList: unknown[], reservedList: unknown[]}} */ const slotRepository = layer.slotRepository const slotClass = (slotRepository._stagingList[0] ?? slotRepository.reservedList[0]).constructor while (true) { const currentSlot = slotRepository._stagingList.length + slotRepository.reservedList.length console.log(currentSlot) if (currentSlot > EXPECT_SLOT_COUNT) { if (slotRepository.reservedList.length) { slotRepository.reservedList.pop() } else { slotRepository._stagingList.pop() } } else if (currentSlot < EXPECT_SLOT_COUNT) { const slot = new slotClass slotRepository.reservedList.push(slot) } else { break } } orig.call(this, layer) } console.log("registerLayerProcessorEvents replaced. original:", orig) observer.disconnect() break } } }) observer.observe(document.getElementById("js-app"), { childList: true, subtree: true, }) })()