直播弹幕控制

自动关闭直播弹幕.

目前为 2020-07-27 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Live Danmaku Controller
  3. // @name:en-US Live Danmaku Controller
  4. // @name:zh-CN 直播弹幕控制
  5. // @description Auto turn off live danmaku.
  6. // @description:en-US Auto turn off live danmaku.
  7. // @description:zh-CN 自动关闭直播弹幕.
  8. // @namespace live-danmaku-controller
  9. // @version 2020.07.27.1
  10. // @author Akatsuki
  11. // @license MIT License
  12. // @grant GM_info
  13. // @run-at document-idle
  14. // @match *://live.bilibili.com/*
  15. // @match *://www.douyu.com/*
  16. // @match *://www.huya.com/*
  17. // @match *://www.yy.com/*
  18. // ==/UserScript==
  19.  
  20. 'use strict'
  21.  
  22. var selector = {
  23. 'live.bilibili.com': {
  24. 'on': "i[class='live-icon-danmaku-on']",
  25. 'off': "i[class='live-icon-danmaku-off']"
  26. },
  27. 'www.douyu.com': {
  28. 'on': "div[class^='showdanmu-']:not([class*='removed-'])",
  29. 'off': "div[class^='hidedanmu-']:not([class*='removed-'])"
  30. },
  31. 'www.huya.com': {
  32. 'on': "div[class='danmu-show-btn'][title='关闭弹幕']",
  33. 'off': "div[class='danmu-show-btn danmu-hide-btn'][title='开启弹幕']"
  34. },
  35. 'www.yy.com': {
  36. 'on': "div[class~='yc__bullet-comments-btn'][title='关闭弹幕']",
  37. 'off': "div[class~='yc__bullet-comments-btn'][title='打开弹幕']"
  38. }
  39. }
  40.  
  41. var delay_site = [
  42. 'www.yy.com'
  43. ]
  44.  
  45. var live_site = document.location.hostname
  46.  
  47. // Danmaku disabler.
  48. function disable_danmaku() {
  49. var button_on = document.querySelector(selector[live_site].on)
  50. if (button_on !== null) {
  51. button_on.click()
  52. }
  53. setTimeout(() => {
  54. if (document.querySelector(selector[live_site].off) === null) {
  55. disable_danmaku()
  56. }
  57. }, 500)
  58. }
  59.  
  60. // Delay danmaku disabler for some sites. (delay 10s)
  61. // To fix the button showing as OFF, but danmaku still appear.
  62. if (delay_site.includes(live_site)) {
  63. setTimeout(disable_danmaku, 10000)
  64. } else (
  65. disable_danmaku()
  66. )

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址