虚拟主播观众指示器

B站评论区自动标注虚拟主播观众成分,依据是动态里是否有虚拟主播内容(基于新三相之力一些小的修改)

目前為 2022-09-13 提交的版本,檢視 最新版本

// ==UserScript==
// @name         虚拟主播观众指示器
// @namespace    雪泽月
// @version      0.1.1
// @description  B站评论区自动标注虚拟主播观众成分,依据是动态里是否有虚拟主播内容(基于新三相之力一些小的修改)
// @author       xulaupuz&nightswan&雪泽月
// @match        https://www.bilibili.com/video/*
// @match        https://t.bilibili.com/*
// @match        https://space.bilibili.com/*
// @match        https://space.bilibili.com/*
// @match        https://www.bilibili.com/read/*
// @icon         https://static.hdslb.com/images/favicon.ico
// @connect      bilibili.com
// @grant        GM_xmlhttpRequest
// @license MIT
// @run-at document-end
// ==/UserScript==
 
 
(function () {
    'use strict';
    const unknown = new Set()
 
    //是否显示vtuber
    let bshow = false
 
    //成分,可自定义
    const nanamiyou = new Set()
    const no_nanamiyou = new Set()
    const azusayou = new Set()
    const no_azusayou = new Set()
    const keroyou = new Set()
    const no_keroyou = new Set()
    const xiaohaizi = new Set()
    const no_xiaohaizi = new Set()
    const nanamiazusa = new Set()
    const no_nanamiazusa = new Set()
    const nanamikero = new Set()
    const no_nanamikero = new Set()
    const keroazusa = new Set()
    const no_keroazusa = new Set()
    const nor = new Set()
    const no_nor = new Set()
    const eoe = new Set()
    const no_eoe = new Set()
    const asoul = new Set()
    const no_asoul = new Set()
    const cheoe = new Set()
    const no_cheoe = new Set()
    const gcp = new Set()
    const no_gcp = new Set()
    const sansan = new Set()
    const no_sansan = new Set()
    const vrx = new Set()
    const no_vrx = new Set()
 
    //关键词,可自定义
    const keyword_nanami = "七海"
    const keyword_azusa = "阿梓从小"
    const keyword_kero = "小可学妹"
    const keyword_eoe = "EOE组合"
    const keyword_asoul = "A-SOUL"
    const keyword_cheoe = "塔菲"
    const keyword_gcp = "東雪"
    const keyword_sansan = "啵啵小狗"
    const keyword_vrx = "VirtuaReal"
 
    //贴上标签,可自定义
    const tag_nor = " 【纯路人】"
    const tag_nanami = " 【脆脆鲨】"
    const tag_azusa = " 【小孩梓】"
    const tag_kero = " 【可可音】"
    const tag_nanamiazusa = " 【梓鲨小队】"
    const tag_nanamikero = " 【鲨可棒】"
    const tag_azusakero = " 【梓可糖浆】"
    const tag_xiaohaizi = " 【小海梓】"
    const tag_eoe = " E团粉"
    const tag_asoul = " A团粉"
    const tag_cheoe = " 雏草姬"
    const tag_gcp = " 棺材铺"
    const tag_sansan = " 33S1"
    const tag_vrx = " 维阿信"
 
 
    const blog = 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?&host_mid='
    const is_new = document.getElementsByClassName('item goback').length != 0 // 检测是不是新版
 
    //标签颜色,可自定义,默认为B站会员色
    const tag_nor_Inner = "<b style='color: #11DD77'>" + tag_nor + "</b>"
    const tag_nanami_Inner = "<b style='color: #4365ED'>" + tag_nanami + "</b>"
    const tag_azusa_Inner = "<b style='color: #7D4F9E'>" + tag_azusa + "</b>"
    const tag_kero_Inner = "<b style='color: #D19275'>" + tag_kero + "</b>"
    const tag_nanamiazusa_Inner = "<b style='color: #FF0000'>" + tag_nanamiazusa + "</b>"
    const tag_nanamikero_Inner = "<b style='color: #FF0000'>" + tag_nanamikero + "</b>"
    const tag_keroazusa_Inner = "<b style='color: #FF0000'>" + tag_azusakero + "</b>"
    const tag_xiaohaizi_Inner = "<b style='color: #FFD700'>" + tag_xiaohaizi + "</b>"
    const tag_eoe_Inner = "<b style='color: #254680'>" + tag_eoe + "</b>"
 
    const tag_asoul_Inner = "<b style='color: #946845'>" + tag_asoul + "</b>"
    const tag_cheoe_Inner = "<b style='color: #946845'>" + tag_cheoe + "</b>"
    const tag_gcp_Inner = "<b style='color: #946845'>" + tag_gcp + "</b>"
    const tag_sansan_Inner = "<b style='color: #946845'>" + tag_sansan + "</b>"
    const tag_vrx_Inner = "<b style='color: #946845'>" + tag_vrx + "</b>"
 
 
    const get_pid = (c) => {
        if (is_new) {
            return c.dataset['userId']
        } else {
            return c.children[0]['href'].replace(/[^\d]/g, "")
        }
    }
 
    const get_comment_list = () => {
        if (is_new) {
            let lst = new Set()
            for (let c of document.getElementsByClassName('user-name')) {
                lst.add(c)
            }
            for (let c of document.getElementsByClassName('sub-user-name')) {
                lst.add(c)
            }
            return lst
        } else {
            return document.getElementsByClassName('user')
        }
    }
 
 
    console.log(is_new)
    console.log("正常加载")
 
 
    let jiance = setInterval(() => {
        let commentlist = get_comment_list()
        if (commentlist.length != 0) {
            // clearInterval(jiance)
            commentlist.forEach(c => {
                let pid = get_pid(c)
                if (eoe.has(pid)) {
                    if (c.textContent.includes(tag_eoe) === false) {
                        c.innerHTML += tag_eoe_Inner
                    }
                    return
                } else if (no_xiaohaizi.has(pid)) {
                    // do nothing
                    return
                }
                if (asoul.has(pid)) {
                    if (c.textContent.includes(tag_asoul) === false) {
                        c.innerHTML += tag_asoul_Inner
                    }
                    return
                } else if (no_asoul.has(pid)) {
                    // do nothing
                    return
                }
                if (cheoe.has(pid)) {
                    if (c.textContent.includes(tag_cheoe) === false) {
                        c.innerHTML += tag_cheoe_Inner
                    }
                    return
                } else if (no_cheoe.has(pid)) {
                    // do nothing
                    return
                }
                if (gcp.has(pid)) {
                    if (c.textContent.includes(tag_gcp) === false) {
                        c.innerHTML += tag_gcp_Inner
                    }
                    return
                } else if (no_gcp.has(pid)) {
                    // do nothing
                    return
                }
                if (sansan.has(pid)) {
                    if (c.textContent.includes(tag_sansan) === false) {
                        c.innerHTML += tag_sansan_Inner
                    }
                    return
                } else if (no_sansan.has(pid)) {
                    // do nothing
                    return
                }
                if (vrx.has(pid)) {
                    if (c.textContent.includes(tag_vrx) === false) {
                        c.innerHTML += tag_vrx_Inner
                    }
                    return
                } else if (no_vrx.has(pid)) {
                    // do nothing
                    return
                }
                if (xiaohaizi.has(pid)) {
                    if (c.textContent.includes(tag_xiaohaizi) === false) {
                        c.innerHTML += tag_xiaohaizi_Inner
                    }
                    return
                } else if (no_xiaohaizi.has(pid)) {
                    // do nothing
                    return
                }
                if (nanamikero.has(pid)) {
                    if (c.textContent.includes(tag_nanamikero) === false) {
                        c.innerHTML += tag_nanamikero_Inner
                    }
                    return
                } else if (no_nanamiazusa.has(pid)) {
                    // do nothing
                    return
                }
                if (keroazusa.has(pid)) {
                    if (c.textContent.includes(tag_keroazusa) === false) {
                        c.innerHTML += tag_keroazusa_Inner
                    }
                    return
                } else if (no_xiaohaizi.has(pid)) {
                    // do nothing
                    return
                }
                if (nanamiazusa.has(pid)) {
                    if (c.textContent.includes(tag_nanamiazusa) === false) {
                        c.innerHTML += tag_nanamiazusa_Inner
                    }
                    return
                } else if (no_nanamiazusa.has(pid)) {
                    // do nothing
                    return
                }
                if (nanamiyou.has(pid)) {
                    if (c.textContent.includes(tag_nanami) === false) {
                        c.innerHTML += tag_nanami_Inner
                    }
                    return
                } else if (no_nanamiyou.has(pid)) {
                    // do nothing
                    return
                }
 
                if (azusayou.has(pid)) {
                    if (c.textContent.includes(tag_azusa) === false) {
                        c.innerHTML += tag_azusa_Inner
                    }
                    return
                } else if (no_azusayou.has(pid)) {
                    // do nothing
                    return
                }
 
                if (keroyou.has(pid)) {
                    if (c.textContent.includes(tag_kero) === false) {
                        c.innerHTML += tag_kero_Inner
                    }
                    return
                } else if (no_keroyou.has(pid)) {
                    // do nothing
                    return
                }
                if (nor.has(pid)) {
                    if (c.textContent.includes(tag_nor) === false) {
                        c.innerHTML += tag_nor_Inner
                    }
                    return
                } else if (no_nor.has(pid)) {
                    // do nothing
                    return
                }
                unknown.add(pid)
                //console.log(pid)
                let blogurl = blog + pid
                // let xhr = new XMLHttpRequest()
                GM_xmlhttpRequest({
                    method: "get",
                    url: blogurl,
                    data: '',
                    headers: {
                        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'
                    },
                    onload: function (res) {
                        if (res.status === 200) {
                            //console.log('成功')
                            let st = JSON.stringify(JSON.parse(res.response).data)
                            unknown.delete(pid)
                            //vtuber
                            if (bshow && (st.includes(keyword_asoul) || st.includes(keyword_cheoe) || st.includes(keyword_gcp))) {
                                c.innerHTML += "<b style='color: #946845' >【 Vtuber |  "
                                //添加A-SOUL标签
                                if (st.includes(keyword_asoul)) {
                                    c.innerHTML += tag_asoul_Inner
                                    asoul.add(pid)
                                } else {
                                    no_asoul.add(pid)
                                }
                                //添加塔菲标签
                                if (st.includes(keyword_cheoe)) {
                                    c.innerHTML += tag_cheoe_Inner
                                    cheoe.add(pid)
                                } else {
                                    no_cheoe.add(pid)
                                }
                                //添加東雪莲标签
                                if (st.includes(keyword_gcp)) {
                                    c.innerHTML += tag_gcp_Inner
                                    gcp.add(pid)
                                } else {
                                    no_gcp.add(pid)
                                }
                                //添加啵啵小狗标签
                                if (st.includes(keyword_sansan)) {
                                    c.innerHTML += tag_sansan_Inner
                                    sansan.add(pid)
                                } else {
                                    no_sansan.add(pid)
                                }
                                //添加VirtuaReal!标签
                                if (st.includes(keyword_vrx)) {
                                    c.innerHTML += tag_vrx_Inner
                                    vrx.add(pid)
                                } else {
                                    no_vrx.add(pid)
                                }
                                c.innerHTML += "<b style='color: #946845' >】</b>"
                            }
 
                            //添加小海梓标签
                            if (st.includes(keyword_kero) && st.includes(keyword_nanami) && st.includes(keyword_azusa)) {
                                c.innerHTML += tag_xiaohaizi_Inner
                                xiaohaizi.add(pid)
                            } else {
                                no_xiaohaizi.add(pid)
                            }
                            //添加梓鲨小队标签
                            if (st.includes(keyword_nanami) && st.includes(keyword_azusa) && !st.includes(keyword_kero)) {
                                c.innerHTML += tag_nanamiazusa_Inner
                                nanamiazusa.add(pid)
                            } else {
                                no_nanamiazusa.add(pid)
                            }
                            //添加鲨可棒标签
                            if (st.includes(keyword_nanami) && !st.includes(keyword_azusa) && st.includes(keyword_kero)) {
                                c.innerHTML += tag_nanamikero_Inner
                                nanamikero.add(pid)
                            } else {
                                no_nanamikero.add(pid)
                            }
                            //添加御三家标签
                            if (!st.includes(keyword_nanami) && st.includes(keyword_azusa) && st.includes(keyword_kero)) {
                                c.innerHTML += tag_keroazusa_Inner
                                keroazusa.add(pid)
                            } else {
                                no_keroazusa.add(pid)
                            }
                            //添加七海标签
                            if (st.includes(keyword_nanami) && !st.includes(keyword_azusa) && !st.includes(keyword_kero)) {
                                c.innerHTML += tag_nanami_Inner
                                nanamiyou.add(pid)
                            } else {
                                no_nanamiyou.add(pid)
                            }
                            //添加阿梓标签
                            if (!st.includes(keyword_nanami) && st.includes(keyword_azusa) && !st.includes(keyword_kero)) {
                                c.innerHTML += tag_azusa_Inner
                                azusayou.add(pid)
                            } else {
                                no_azusayou.add(pid)
                            }
                            //添加小可标签
                            if (!st.includes(keyword_nanami) && !st.includes(keyword_azusa) && st.includes(keyword_kero)) {
                                c.innerHTML += tag_kero_Inner
                                keroyou.add(pid)
                            } else {
                                no_keroyou.add(pid)
                            }
                            //添加E团标签
                            if (st.includes(keyword_eoe)) {
                                c.innerHTML += tag_eoe_Inner
                                eoe.add(pid)
                                return
                            } else {
                                no_eoe.add(pid)
                            }
                            //添加路人标签
                            if (!st.includes(keyword_kero) && !st.includes(keyword_nanami) && !st.includes(keyword_azusa)) {
                                c.innerHTML += tag_nor_Inner
                                nor.add(pid)
                            } else {
                                no_nor.add(pid)
                            }
                        } else {
                            console.log('失败')
                            console.log(res)
                        }
                    },
                });
            });
        }
    }, 4000)
})();

QingJ © 2025

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