复读机自动弹幕发射器

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

目前为 2020-03-11 提交的版本。查看 最新版本

  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.1.0
  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: 85px;height: 22px;border-radius: 5px;right: 10px;top: 72%;'
  18. let css2 = 'background: #ffffff;overflow: hidden;z-index: 999;position: fixed;padding:5px;text-align:center;width: 110px;height: 100px;box-sizing: content-box;border: 1px solid #ff921a;border-radius: 5px;right: 10px;top: 72%;display: none;';
  19. let cycle_time;//弹幕周期,单位毫秒 建议设定至6000毫秒以上 过低有系统屏蔽风险
  20. let _cycle_time = 800;//弹幕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. let __mode = false;//复读白字标记
  29. let ___mode = false;//重复复读标记
  30.  
  31. init();//初始化
  32.  
  33. //核心功能函数
  34. function init() {
  35. div1.id = 'DuLunChe2';
  36. div1.id = 'DuLunChe3';
  37. div1.style.cssText = css1;
  38. div2.style.cssText = css2;
  39. div1.innerHTML = '复读机控制台';
  40. div2.innerHTML = '<input type="text" style="width: 100px" placeholder="间隔时间(ms)" id="DuLunCheTime1"/><div style="font-size: 10px;margin-bottom: 2px;"><button id="DuLunCheBtn1" style="display: inline-block; background: #f70; color: #FFFFFF; width:50px; height: 25px; margin: 1px;">出动</button><button id="DuLunCheYinCang1" style="display: inline-block; background: #f70; color: #FFFFFF; width:50px; height: 25px; margin: 1px;">隐藏</div></button><div style="color: black;float: left;width: 100%;font-size: 75%;"><span>套娃模式:</span><input type="checkbox" id="dlc_btn99" value="0" style="display: block;position: relative;float: right;margin-right: 20px;"/></div><div style="color: black;float: left;width: 100%;font-size: 75%;"><span>不复读白字:</span><input type="checkbox" id="dlc_btn98" value="0" style="display: block;position: relative;float: right;margin-right: 20px;"/></div><div style="color: black;float: left;width: 100%;font-size: 75%;"><span>不重复复读:</span><input type="checkbox" id="dlc_btn97" value="0" style="display: block;position: relative;float: right;margin-right: 20px;"/></div>';
  41. div1.onclick = () => {
  42. div2.style.setProperty('display','block');
  43. if(!tip){
  44. tip = true;
  45. alert('本插件由斗鱼用户重载操作符制作,项目地址:https://github.com/zhenshiluosuo/Storyteller-AutoBarrageForDouyuTV/ 有问题请私信斗鱼重载操作符,为了自己的账号和他人观看体验,建议发言间隔调至8000以上,喜欢的好兄弟github打个星星吧~求求了!!!');
  46. }
  47. };
  48. document.body.appendChild(div1);
  49. document.body.appendChild(div2);
  50. document.getElementById('DuLunCheYinCang1').onclick = () => {
  51. div2.style.setProperty('display','none');
  52. };
  53. document.getElementById('DuLunCheBtn1').onclick = () => {
  54. if(document.getElementById('DuLunCheBtn1').innerText === '出动') run();
  55. else finish();
  56. };
  57. document.getElementById('dlc_btn99').onclick = () => {
  58. if(document.getElementById('dlc_btn99').checked){
  59. _mode = true;
  60. }else{
  61. _mode = false;
  62. }
  63. };
  64. document.getElementById('dlc_btn98').onclick = () => {
  65. if(document.getElementById('dlc_btn98').checked){
  66. __mode = true;
  67. }else{
  68. __mode = false;
  69. }
  70. };
  71. document.getElementById('dlc_btn98').onclick = () => {
  72. if(document.getElementById('dlc_btn98').checked){
  73. ___mode = true;
  74. }else{
  75. ___mode = false;
  76. }
  77. };
  78. danmu_interval = setInterval(() => {
  79. if(document.getElementsByClassName('danmu-6e95c1')[0].childNodes.length){
  80. div_manmu = document.getElementsByClassName('danmu-6e95c1')[0];
  81. div_wenzi = document.getElementById('js-barrage-list');
  82. div_manmu.addEventListener('DOMNodeInserted', function () {
  83. let _sentence = sentence;
  84. if(_mode){
  85. if(__mode && 'Barrage-content' === div_wenzi.childNodes[div_wenzi.childNodes.length - 1].getElementsByClassName('Barrage-content')[0].className){
  86. return;
  87. }
  88. 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;
  89. _ready = true;
  90.  
  91. }else{
  92. let len = div_manmu.childNodes.length;
  93. if(len){
  94. let _temp = div_manmu.childNodes[Math.floor((Math.random() * len))];
  95. let _color = _temp.style.color;
  96. if(!__mode || (__mode && _color.length)){
  97. _ready = true;
  98. sentence = _temp.innerText;
  99. }
  100. }
  101. }
  102. if(___mode && _ready){
  103. if(_sentence === sentence){
  104. _ready = false;
  105. }
  106. }
  107. },false);
  108. clearInterval(danmu_interval);
  109. }
  110. }, _cycle_time);
  111. }
  112. //发射弹幕
  113. function run() {
  114. let btn = document.getElementsByClassName('ChatSend-button')[0];
  115. let txt = document.getElementsByClassName('ChatSend-txt')[0];
  116. document.getElementById('DuLunCheBtn1').innerText = '中止';
  117. cycle_time = parseInt(document.getElementById('DuLunCheTime1').value);
  118. if(cycle_time <= 2999 || !cycle_time) {
  119. alert('请珍惜账号 加大发言间隔!');
  120. finish();
  121. document.getElementById('DuLunCheTime1').value = '9999';
  122. return;
  123. }
  124. interval = setInterval(() => {
  125. if(txt.value === '' && _ready && btn.innerHTML === '发送'){//输入框中有内容时等待用户发送完成后再继续
  126. txt.value = sentence;
  127. btn.click();
  128. _ready = false;
  129. }
  130. }, cycle_time);
  131. }
  132. //结束发射
  133. function finish() {
  134. document.getElementById('DuLunCheBtn1').innerText = '出动';
  135. clearInterval(interval);
  136. }
  137. })();

QingJ © 2025

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