您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Live stream filtering with real-time counter
当前为
// ==UserScript== // @name Bilibili Live Stream Filter // @namespace http://tampermonkey.net/ // @version 1.0 // @description Live stream filtering with real-time counter // @author Gavin Hon // @match https://live.bilibili.com/* // @grant none // @run-at document-idle // @license MIT // ==/UserScript== (function() { 'use strict'; const LIVE_FILTER_SELECTOR = '.face.living'; const TARGET_CONTAINER_SELECTOR = '.single'; const NAME_SELECTOR = '.name'; const BLOCKED_NAME = '花芽荔枝'; const COUNTER_SELECTOR = '.mount'; const COUNTER_PREFIX = ' (Streaming: '; let liveCount = 0; let counterElement = null; function updateCounter() { if (!counterElement) { counterElement = document.querySelector(COUNTER_SELECTOR); if (!counterElement) return; } // Remove existing counter const currentText = counterElement.textContent; const regex = /(.*?)(\s*\(Streaming:\s*\d+\))/; const cleanText = currentText.replace(regex, '$1'); // Update with new count counterElement.textContent = `${cleanText}${COUNTER_PREFIX}${liveCount})`; } function filterLiveStreamers() { liveCount = 0; // Reset counter document.querySelectorAll(TARGET_CONTAINER_SELECTOR).forEach(container => { // Name filtering const nameElement = container.querySelector(NAME_SELECTOR); if (nameElement?.textContent.includes(BLOCKED_NAME)) { container.remove(); return; } // Live status check const isLive = container.querySelector(LIVE_FILTER_SELECTOR); if (!isLive) { container.remove(); } else { liveCount++; // Count valid live streamers } }); updateCounter(); } // Initial execution filterLiveStreamers(); // Dynamic content handling new MutationObserver(mutations => { filterLiveStreamers(); }).observe(document.body, { subtree: true, childList: true }); // SPA navigation handling window.addEventListener('popstate', filterLiveStreamers); window.addEventListener('pushstate', filterLiveStreamers); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址