您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
点击两侧空白收起B站动态评论(包括 up 空间动态)
// ==UserScript== // @name BiliFold - 收起动态评论 // @namespace https://github.com/F-park/BiliFold // @version 0.1.1 // @description 点击两侧空白收起B站动态评论(包括 up 空间动态) // @author F-park // @license MIT // @source https://github.com/F-park/BiliFold // @supportURL https://github.com/F-park/BiliFold/issues // @match https://space.bilibili.com/* // @match https://t.bilibili.com/ // @match https://t.bilibili.com/?* // @icon https://www.bilibili.com/favicon.ico // @grant none // ==/UserScript== (function() { 'use strict'; const selectors = []; const {origin} = window.location; if (origin == "https://space.bilibili.com") { selectors.push("div:has(> #page-dynamic)"); selectors.push("#page-dynamic"); } else if (origin == "https://t.bilibili.com") { selectors.push("aside.left"); selectors.push("aside.right"); } const pageObserver = new MutationObserver((mutationList, observer) => { const targets = document.querySelectorAll(selectors.join(",")); if (targets.length == 0) { return; } for (const target of targets) { target.addEventListener('click', (ev) => { if (ev.target == target) { // 只找有评论区的 for (const el of document.querySelectorAll(".bili-dyn-item:has(.bili-dyn-item__panel)")) { if (el.getBoundingClientRect().top < ev.y && ev.y < el.getBoundingClientRect().bottom) { // 65为顶栏高度 const topBoundary = el.querySelector(".bili-dyn-item__panel").getBoundingClientRect().top - 65; if (topBoundary < 0) { window.scrollBy({top: topBoundary}); } el.getElementsByClassName("bili-dyn-action comment active")[0].click(); } } } }) } pageObserver.disconnect(); }) if (selectors.length > 0) { pageObserver.observe(document.body, { childList: true, subtree: true, }) } })();