代码:
{ let jq = null if (!document.querySelector('#jquery')) { jq = document.createElement('script') jq.id = 'jquery' jq.src = 'https://libs.baidu.com/jquery/1.10.2/jquery.min.js' document.body.appendChild(jq) } else { jq = document.querySelector('#jquery') } window.timer && clearInterval(window.timer) setTimeout(() => { let 上一条弹幕 = '' window.timer = setInterval(() => { const $所有条 = $('#island_4a5da .rXSKGskq .webcast-chatroom___item') const 当前弹幕 = $(`#island_4a5da .rXSKGskq .webcast-chatroom___item:eq(${$所有条.length - 2}) .WsJsvMP9`).text() if (当前弹幕 !== 上一条弹幕) { 上一条弹幕 = 当前弹幕 console.log('当前弹幕', 当前弹幕) } //如果弹出长时间无操作,已暂停播放 则自动关闭 if ($('.ezAK2PYX').length > 0) { $('.ezAK2PYX .JL05k7eS').click() } }, 100) }, 1000) }