复读机自动弹幕发射器

适配斗鱼直播平台的自动弹幕发射器 随机复制复读机 Github:https://github.com/zhenshiluosuo/Storyteller-AutoBarrageForDouyuTV

目前为 2020-02-28 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @icon https://www.douyu.com/favicon.ico
  3. // @name 复读机自动弹幕发射器
  4. // @namespace https://github.com/zhenshiluosuo/Storyteller-AutoBarrageForDouyuTV
  5. // @author 闪光魔法师
  6. // @description 适配斗鱼直播平台的自动弹幕发射器 随机复制复读机 Github:https://github.com/zhenshiluosuo/Storyteller-AutoBarrageForDouyuTV
  7. // @match *://www.douyu.com/*
  8. // @version 0.0.2
  9. // @grant none
  10. // ==/UserScript==
  11. (function () {
  12. 'use strict';
  13.  
  14. let tip = false;
  15. let div1 = document.createElement('div');//默认悬浮窗
  16. let div2 = document.createElement('div');//控制台
  17. let css1 = 'background: #FFB5C5;color:#ffffff;overflow: hidden;z-index: 998;position: fixed;padding:5px;text-align:center;width: 75px;height: 22px;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;right: 10px;top: 72%;'
  18. let css2 = 'background: #E5E4E4;color:#ffffff;overflow: hidden;z-index: 999;position: fixed;padding:5px;text-align:center;width: 100px;height: 70px;border-color: #FFFFFF;border: 3px;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;right: 10px;top: 72%;display: none;';
  19. let cycle_time;//弹幕周期,单位毫秒 建议设定至6000毫秒以上 过低有系统屏蔽风险
  20. let _cycle_time = 1000;//弹幕div定时器
  21. let sentence;//复制的弹幕
  22. let interval;//发射定时器
  23. let danmu_interval;//等待弹幕div加载定时器
  24. let _ready = false;//弹幕div加载标记
  25. let div_manmu;//网页弹幕div
  26. let div_wenzi;//网页聊天室div
  27. let _mode = false;//套娃模式标记
  28.  
  29. init();//初始化
  30.  
  31. //核心功能函数
  32. function init() {
  33. div1.id = 'DuLunChe2';
  34. div1.id = 'DuLunChe3';
  35. div1.style.cssText = css1;
  36. div2.style.cssText = css2;
  37. div1.innerHTML = '复读机控制台';
  38. div2.innerHTML = '<input type="text" style="width: 80px" placeholder="间隔时间(ms)" id="DuLunCheTime1"/><button id="DuLunCheBtn1" style="background-color: #FFFFFF;">出动!</button><br><button id="DuLunCheYinCang1" style="background-color: #FFFFFF;">隐藏控制台</button><div style="font-size: 75%;color: black;float: left;">套娃模式:<input type="checkbox" id="dlc_btn99" value="0" /></div>';
  39. div1.onclick = () => {
  40. div2.style.setProperty('display','block');
  41. if(!tip){
  42. tip = true;
  43. alert('本插件由斗鱼用户重载操作符制作,项目地址:https://github.com/zhenshiluosuo/Storyteller-AutoBarrageForDouyuTV/ 有问题请私信斗鱼重载操作符,为了自己的账号和他人观看体验,建议发言间隔调至8000以上,喜欢的好兄弟github打个星星吧~求求了!!!');
  44. }
  45. };
  46. document.body.appendChild(div1);
  47. document.body.appendChild(div2);
  48. document.getElementById('DuLunCheYinCang1').onclick = () => {
  49. div2.style.setProperty('display','none');
  50. };
  51. document.getElementById('DuLunCheBtn1').onclick = () => {
  52. if(document.getElementById('DuLunCheBtn1').innerText === '出动!') run();
  53. else finish();
  54. };
  55. document.getElementById('dlc_btn99').onclick = () => {
  56. if(document.getElementById('dlc_btn99').checked){
  57. _mode = true;
  58. }else{
  59. _mode = false;
  60. }
  61. };
  62. danmu_interval = setInterval(() => {
  63. if(document.getElementsByClassName('danmu-6e95c1')[0].childNodes.length){
  64. div_manmu = document.getElementsByClassName('danmu-6e95c1')[0];
  65. div_wenzi = document.getElementById('js-barrage-list');
  66. div_manmu.addEventListener('DOMNodeInserted', function () {
  67. if(_mode){
  68. sentence = '@' + div_wenzi.childNodes[div_wenzi.childNodes.length - 1].getElementsByClassName('Barrage-nickName')[0].innerText + div_wenzi.childNodes[div_wenzi.childNodes.length - 1].getElementsByClassName('Barrage-content')[0].innerText;
  69. _ready = true;
  70. }else{
  71. let len = div_manmu.childNodes.length;
  72. if(len){
  73. sentence = div_manmu.childNodes[Math.floor((Math.random() * len))].innerText;
  74. _ready = true;
  75. }
  76. }
  77. },false);
  78. clearInterval(danmu_interval);
  79. }
  80. }, _cycle_time);
  81. }
  82. //发射弹幕
  83. function run() {
  84. let btn = document.getElementsByClassName('ChatSend-button')[0];
  85. let txt = document.getElementsByClassName('ChatSend-txt')[0];
  86. document.getElementById('DuLunCheBtn1').innerText = '中止';
  87. cycle_time = parseInt(document.getElementById('DuLunCheTime1').value);
  88. if(cycle_time <= 2999) {
  89. alert('请珍惜账号 加大发言间隔!');
  90. finish();
  91. document.getElementById('DuLunCheTime1').value = '9999';
  92. return;
  93. }
  94. interval = setInterval(() => {
  95. if(txt.value === '' && _ready && btn.innerHTML === '发送'){//输入框中有内容时等待用户发送完成后再继续
  96. txt.value = sentence;
  97. btn.click();
  98. _ready = false;
  99. }
  100. }, cycle_time);
  101. }
  102. //结束发射
  103. function finish() {
  104. document.getElementById('DuLunCheBtn1').innerText = '出动!';
  105. clearInterval(interval);
  106. }
  107. })();

QingJ © 2025

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