blivedm-recover

恢复B站直播弹幕

Tính đến 30-05-2019. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         blivedm-recover
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  恢复B站直播弹幕
// @author       xfgryujk
// @include      /https?:\/\/live\.bilibili\.com\/\d+\??.*/
// @grant        none
// ==/UserScript==

(function () {
  let realInitialize = window.DanmakuWebSocket.prototype.initialize
  window.DanmakuWebSocket.prototype.initialize = function (config) {
    // console.log('initialize', config)
    let realOnReceivedMessage = config.onReceivedMessage
    config.onReceivedMessage = function (msg) {
      let params = msg.cmd.split(':')
      if (params.length > 4 && params[0] === 'DANMU_MSG') {
        params[4] = '0' // 和谐级别,0都发,1不发评论,2不发弹幕,3都不发
        msg.cmd = params.join(':')
      }
      // console.log('onReceivedMessage', msg)
      realOnReceivedMessage.call(this, msg)
    }
    return realInitialize.call(this, config)
  }
})()