Live Danmaku Controller

Auto turn off live danmaku

Verze ze dne 28. 07. 2020. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name                Live Danmaku Controller
// @name:en-US          Live Danmaku Controller
// @name:zh-CN          直播弹幕控制
// @description         Auto turn off live danmaku
// @description:en-US   Auto turn off live danmaku
// @description:zh-CN   自动关闭直播弹幕
// @namespace           live-danmaku-controller
// @version             2020.07.28
// @author              Akatsuki
// @license             MIT License
// @grant               GM_info
// @run-at              document-idle
// @match               *://live.bilibili.com/*
// @match               *://www.douyu.com/*
// @match               *://www.huya.com/*
// @match               *://www.yy.com/*
// ==/UserScript==

'use strict'

const selector = {
  'live.bilibili.com': {
    on: "i[class='live-icon-danmaku-on']",
    off: "i[class='live-icon-danmaku-off']"
  },
  'www.douyu.com': {
    on: "div[class^='showdanmu-']:not([class*='removed-'])",
    off: "div[class^='hidedanmu-']:not([class*='removed-'])"
  },
  'www.huya.com': {
    on: "div[class='danmu-show-btn'][title='关闭弹幕']",
    off: "div[class='danmu-show-btn danmu-hide-btn'][title='开启弹幕']"
  },
  'www.yy.com': {
    on: "div[class~='yc__bullet-comments-btn'][title='关闭弹幕']",
    off: "div[class~='yc__bullet-comments-btn'][title='打开弹幕']"
  }
}

const delaySite = ['www.yy.com']

var liveSite = document.location.hostname

// Danmaku disabler
function disableDanmaku () {
  var buttonOn = document.querySelector(selector[liveSite].on)
  if (buttonOn !== null) {
    buttonOn.click()
  }
  setTimeout(() => {
    if (document.querySelector(selector[liveSite].off) === null) {
      disableDanmaku()
    }
  }, 500)
}

// Delay danmaku disabler for some sites (Delay 10s)
// Fix the button is showing as OFF, but danmaku still appear
if (delaySite.includes(liveSite)) {
  setTimeout(disableDanmaku, 10000)
} else {
  disableDanmaku()
}