blivedm-recover

恢复B站直播弹幕

Stan na 30-05-2019. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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