高亮个别用户的弹幕

高亮个别用户的弹幕, 有时候找一些特殊人物(其他直播主出现在直播房间)用

目前為 2020-12-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name         高亮个别用户的弹幕
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  高亮个别用户的弹幕, 有时候找一些特殊人物(其他直播主出现在直播房间)用
// @author       Eric Lam
// @include      /https?:\/\/live\.bilibili\.com\/(blanc\/)?\d+\??.*/
// @require      https://code.jquery.com/jquery-3.5.1.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.10/pako.min.js
// @require      https://gf.qytechs.cn/scripts/417560-bliveproxy/code/bliveproxy.js?version=875812
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    console.log('using highlight filter')
    // 设定

    // 高亮用户 ID
    const highlightUsers = [
        396024008, // 日本兄贵
        604890122, // 日本兄贵
        623441609, // 凤玲天天 (DD)
        1618670884, // 日本兄贵
        840358977 // 日本兄贵
    ]

    const settings = {
       // 颜色
       // 颜色列表 https://my.oschina.net/mye/blog/213309
       color: 0x66FF00,
       // 透明度
       opacity: 1.0
    }

    // 代码
    const highlight = []
    bliveproxy.addCommandHandler('DANMU_MSG', command => {
        const userId = command.info[2][0]
        if (!highlightUsers.includes(userId)) return
        console.debug('detected highlighted user: '+userId)
        command.info[0][3] = settings.color
        command.info[1] += `(${command.info[2][1]})`
        console.debug(`converted danmaku: ${command.info[1]}`)
        highlight.push(command.info[1])
   })
    const config = { attributes: false, childList: true, subtree: true }
    function danmakuCheckCallback(mutationsList){
        for(const mu of mutationsList){
            if (mu.addedNodes.length < 1) continue
            for (const node of mu.addedNodes){
                //console.log(node)
                const danmaku = node?.innerText?.trim() ?? node?.data?.trim()
                if (danmaku === undefined || danmaku === '') continue
                if (!highlight.includes(danmaku)) continue
                const n = node.innerText !== undefined ? node : node.parentElement
                const jimaku = $(n)
                jimaku.css('opacity', settings.opacity)
            }
        }
    }
   const danmakuObserver = new MutationObserver((mu, obs) => danmakuCheckCallback(mu))
   danmakuObserver.observe($('.bilibili-live-player-video-danmaku')[0], { childList: true, subTree: true})
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址