blivedm-recover

恢复B站直播弹幕

Od 30.05.2019.. Pogledajte najnovija verzija.

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.

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

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)
  }
})()