Greasy Fork

Greasy Fork is available in English.

高亮个别用户的弹幕

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

当前为 2021-01-15 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         高亮个别用户的弹幕
// @namespace    http://tampermonkey.net/
// @version      0.6.2
// @description  高亮个别用户的弹幕, 有时候找一些特殊人物(其他直播主出现在直播房间)用
// @author       Eric Lam
// @include      /https?:\/\/live\.bilibili\.com\/(blanc\/)?\d+\??.*/
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.10/pako.min.js
// @require      http://greasyfork.icu/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, // 日本兄贵
        406805563, // 乙女音
        2299184,  // 古守
        625255764, // 辻蓝佳音瑠
        198297, // 冰糖
        1576121 // paryi
    ]

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

    // 代码
    const hightlights = new Set()
    bliveproxy.addCommandHandler('DANMU_MSG', command => {
        const userId = command.info[2][0]
        //console.debug(userId)
        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]}`)
        hightlights.add(command.info[1])
   })
    const config = { attributes: false, childList: true, subtree: true }
    function danmakuCheckCallback(mutationsList){
        for(const mu of mutationsList){
            for (const node of mu.addedNodes){
                const danmaku = node?.innerText?.trim() ?? node?.data?.trim()
                if (danmaku === undefined || danmaku === '') continue
                if (!hightlights.has(danmaku)) continue
                console.debug('highlighting danmaku: '+danmaku)
                const n = node.innerText !== undefined ? node : node.parentElement
                const jimaku = $(n)
                jimaku.css('opacity', `${settings.opacity}`)
                hightlights.delete(danmaku)
            }
        }
    }
   const danmakuObserver = new MutationObserver((mu, obs) => danmakuCheckCallback(mu))
   danmakuObserver.observe($('.bilibili-live-player-video-danmaku')[0], config)
})();