// ==UserScript== // @name b站vtuber直播同传评论转字幕 // @namespace http://tampermonkey.net/ // @version 0.1.3 // @author You // @match https://live.bilibili.com/* // @grant none // @require https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js // @require https://cdn.staticfile.org/vue/2.6.11/vue.min.js // @description 将vtuber直播时同传man的评论,以类似底部弹幕的形式展现在播放器窗口,免去在众多快速刷过的评论中找同传man的痛苦。 // @downloadURL none // ==/UserScript== (function () { const widgeConfig = { color:'white', fontSize:'50px', bottom:'0px' } window.attensionModul = {} window.attensionModul.app = null window.attensionModul.users = [] window.attensionModul.observe = {} // 添加关注用户 function addAttentionUser(uid) { console.log('add subscribe:', uid) $('textarea:eq(0)').click() if(window.attensionModul.users.indexOf(uid) < 0){ window.attensionModul.users.push(uid) } } // 移除关注用户 function removeAttentionUser() { } //将匹配评论添加到vue变量中对应的字幕dom function setComment(index, comment) { console.log('comment',comment) window.attensionModul.app.comments.splice(index,1,comment) } //评论内容筛选 function chatFilter(nodeList) { for (let item of nodeList) { const uid = item.getAttribute('data-uid') const comment = item.getAttribute('data-danmaku') const index = window.attensionModul.users.indexOf(uid) if (index > -1) { setComment(index, comment) } } } // DOM突变时间监听回调函数 function mutationListener(mutationList) { window.attensionModul.observe.message = mutationList if (window.attensionModul.observe.message[0].addedNodes.length > 0) { chatFilter(window.attensionModul.observe.message[0].addedNodes) } } // 添加字幕组件 ;(function insertCommentWidget() { const container = $('.bilibili-live-player-video-danmaku') if (container.length > 0) { const commentWidget = $('