直播弹幕控制

自动关闭直播弹幕

  1. // ==UserScript==
  2. // @name Live Danmaku Controller
  3. // @name:en-US Live Danmaku Controller
  4. // @name:zh-CN 直播弹幕控制
  5. // @name:zh-TW 直播彈幕控制
  6. // @description Automatically turn off the live streaming danmaku
  7. // @description:en-US Automatically turn off the live streaming danmaku
  8. // @description:zh-CN 自动关闭直播弹幕
  9. // @description:zh-TW 自動關閉直播彈幕
  10. // @namespace live-danmaku-controller
  11. // @version 2021.10.06
  12. // @author Akatsuki Rui
  13. // @license MIT License
  14. // @grant GM_info
  15. // @compatible chrome Since Chrome 49.x
  16. // @compatible firefox Since Firefox 44.x
  17. // @compatible opera Since 17.x
  18. // @run-at document-idle
  19. // @match *://www.douyu.com/*
  20. // @match *://www.huya.com/*
  21. // @match *://www.yy.com/*
  22. // ==/UserScript==
  23.  
  24. "use strict";
  25.  
  26. const SELECTOR = {
  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[id='player-danmu-btn'][title='关闭弹幕']",
  33. off: "div[id='player-danmu-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. // Delay danmaku disabler for some sites (Default 10s)
  42. const DELAY_TIME = 10000;
  43. const DELAY_SITE = ["www.yy.com"];
  44.  
  45. const LIVE_SITE = document.location.hostname;
  46.  
  47. // Danmaku disabler
  48. function disableDanmaku() {
  49. let button = document.querySelector(SELECTOR[LIVE_SITE].on);
  50.  
  51. if (button) {
  52. button.click();
  53. }
  54. setTimeout(() => {
  55. if (document.querySelector(SELECTOR[LIVE_SITE].off) === null) {
  56. disableDanmaku();
  57. }
  58. }, 500);
  59. }
  60.  
  61. // To fix the button is showing as OFF, but danmaku still appear
  62. DELAY_SITE.includes(LIVE_SITE)
  63. ? setTimeout(disableDanmaku, DELAY_TIME)
  64. : disableDanmaku();

QingJ © 2025

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