// ==UserScript== // @icon https://www.douyu.com/favicon.ico // @name 独轮车-说书人自动弹幕发射器 // @namespace https://github.com/zhenshiluosuo/Storyteller-AutoBarrageForDouyuTV // @author 飞天小协警 // @description 适配斗鱼/虎牙/Mildom/b站/ytb直播平台的自动弹幕发射器 抽象独轮车 说书人 Github:https://github.com/zhenshiluosuo/Storyteller-AutoBarrageForDouyuTV // @match *://www.douyu.com/* // @match *://www.huya.com/* // @match *://live.bilibili.com/* // @match *://www.youtube.com/* // @match *://www.mildom.com/* // @require https://greasyfork.org/scripts/414419-st-ex/code/ST_EX.js?version=861721 // @require https://greasyfork.org/scripts/420380-chtext-convert/code/chtext-convert.js?version=892303 // @version 2.5.6 // @license GPLv2 // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_getResourceText // @grant GM_notification // @grant GM_download // @connect sohu.com // @namespace https://greasyfork.org/scripts/396285 // @downloadURL https://update.greasyfork.icu/scripts/396285/%E7%8B%AC%E8%BD%AE%E8%BD%A6-%E8%AF%B4%E4%B9%A6%E4%BA%BA%E8%87%AA%E5%8A%A8%E5%BC%B9%E5%B9%95%E5%8F%91%E5%B0%84%E5%99%A8.user.js // @updateURL https://update.greasyfork.icu/scripts/396285/%E7%8B%AC%E8%BD%AE%E8%BD%A6-%E8%AF%B4%E4%B9%A6%E4%BA%BA%E8%87%AA%E5%8A%A8%E5%BC%B9%E5%B9%95%E5%8F%91%E5%B0%84%E5%99%A8.meta.js // ==/UserScript== (function () { 'use strict'; let tip = false; let div1 = document.createElement('div');//默认悬浮窗 let div2 = document.createElement('div');//控制台 let div3 = document.createElement('div');//计数器 let div5 = document.createElement('div');//快速发射 let div6 = document.createElement('div');//资源库 let div7 = document.createElement('div');//定时设置 let div8 = document.createElement('div');//转换器 let div9 = document.createElement('div');//设置 let css1 = 'background: #D4F2E7;color:#000000;overflow: hidden;z-index: 996;position: fixed;text-align:center;width: 100px;height: 30px;box-sizing: border-box;border: 1px solid #ff921a;border-radius: 5px;padding: 0;right: 5px;top: 25%;display: flex; justify-content: center; align-items: center;line-height: 100%;' let css2 = 'background: #FFFFFF;color:#ffffff;overflow: hidden;z-index: 997;position: fixed;padding:5px;text-align:center;width: 165px;height: 410px;box-sizing: border-box;border: 1px solid #ff921a;border-radius: 5px;right: 5px;top: 25%;display: none;'; let css3 = 'background: #FFFFFF;color:#000000;overflow: hidden;z-index: 999;position:absolute;text-align:center;width: 100%;height: 100%;box-sizing: border-box;border: 1px solid #ff921a;padding:5px;border-radius: 5px;top: 7%;right: 0px;display: none;'; let css6_1 = 'font-size: 12px; cursor: pointer; border: 1px solid #ff921a; height: 25px; margin: 1px; display: flex; justify-content: center; align-items: center; position: relative; float: left; padding: 3px;'; let div2_innerHTML1 = '
屏蔽白字黑奴(斗鱼):
屏蔽绿字色友(斗鱼):
屏蔽粉字男同(斗鱼):
临时应急弹幕(斗鱼):
'; let div3_innerHTML1 = '
计数方式1
 / 
   
计数方式2
 单位:
   
'; let max_danmu_long = 43;//弹幕字数限制 let min_danmu_long = 18;//最小弹幕长度 let error_danmu_long = 25;//防止无法断句弹幕长度 let cycle_time;//弹幕周期,单位毫秒 建议设定至6000毫秒以上 过低有系统屏蔽风险 let min_cycle_time = 3000; let story;//textarea内容 let story_arr = [];//story分段 let time_arr = [];//时间记录 let index;//小说分段 let interval;//小说定时器 let danmu_interval;//等待弹幕div加载定时器 let color_box = [];//禁止的弹幕颜色 let div_manmu;//网页弹幕div let select_flag = false;//功能标记 let radio_flag = false; let radio_change_flag = false; let resource_flag = false; let setting_flag = false; let danmu_helperX = false;//应急弹幕标记 let danmu_count = 0; let danmu_parent = null; let website;//当前站点 0:斗鱼 1:虎牙 2:p站 3:ytb 5:mildom... let btn = null; //发送按钮 let txt = null; //输入框 let dlc_radio_words; //热词 let ytb_iframe;//ytb直播右侧iframe let mouse_flag = false;//鼠标拖动标记 let mouse_throttle = null;//鼠标拖动节流 let mouse_throttle_flag = false;//鼠标拖动节流标记 let mouseDownX; let mouseDownY; let initX; let initY; let dlc_time_state = 0;//定时启动 状态 let dlc_time_flag = false;//定时启动页面标记 let dlc_time_interval = null;//定时启动 定时器 let dlc_time_show_interval = null; let st_h; let st_m; let en_h; let en_m; let chtext_convert_flag = false; //转换器标志 let chtext_convert_backup = ''; ch_info(); init();//初始化 //核心功能函数 function init() { let url = window.location.host; if(url === 'www.douyu.com') { website = 0; } else if(url === 'www.huya.com') { max_danmu_long = 29; min_danmu_long = 15; error_danmu_long = 20; website = 1; } else if(url === 'live.bilibili.com') { if (window.top !== window.self && !document.documentElement.getElementsByClassName('lite-room supportWebp').length) { throw new Error('Frame error!'); } max_danmu_long = 19; min_danmu_long = 10; error_danmu_long = 15; website = 2; } else if(url === 'www.youtube.com') { if (window.top !== window.self) { throw new Error('Frame error!'); } max_danmu_long = 200; min_danmu_long = 30; error_danmu_long = 100; website = 3; } else if(url === 'www.mildom.com') { max_danmu_long = 120; min_danmu_long = 30; error_danmu_long = 80; website = 5; } div1.id = 'DuLunChe1'; div2.id = 'DuLunChe2'; div3.id = 'dlc-select-window'; div5.id = 'dlc-radio-window'; div9.id = 'dlc-setting-window'; div1.style.cssText = css1; div2.style.cssText = css2; div3.style.cssText = css3; div5.style.cssText = css3; div6.style.cssText = css3; div9.style.cssText = css3; div1.innerHTML = '独轮车控制台'; div2.innerHTML = div2_innerHTML1; div3.innerHTML = div3_innerHTML1; div1.onclick = () => { div2.style.setProperty('display','block'); div1.style.setProperty('display','none'); if(!tip){ tip = true; alert('欢迎使用持续更新的独轮车-说书人自动弹幕发射装置,当前版本V2.5.3(Crimson),对本插件的意见和问题可以到Github反馈哦,项目地址:https://github.com/zhenshiluosuo/Storyteller-AutoBarrageForDouyuTV/ 。多句转轮模式每句之间请用回车分隔,为了自己的账号和他人观看体验,建议发言间隔调至8000ms以上,喜欢的好兄弟打个星星吧~求求了!编程独轮车教程:奇数行为下一句发送的间隔毫秒时间,偶数行为发送内容(一行中内容过多挤到下一行也算到上一行中),比如第一行8000,第二行啦啦啦,第三行10000,第四行噜噜噜,则先发送啦啦啦,8秒后发送噜噜噜,10秒后再发送啦啦啦,8秒后发送噜噜噜 部分功能可能在非斗鱼平台上无法使用 定制功能:shinymoon@aliyun.com'); } }; document.body.appendChild(div1); document.body.appendChild(div2); div2.appendChild(div3); div2.appendChild(div5); div2.appendChild(div6); div2.appendChild(div7); div2.appendChild(div8); div2.appendChild(div9); document.getElementById('DuLunCheYincang').onclick = () => { div1.style.setProperty('display','flex'); div2.style.setProperty('display','none'); }; document.getElementById('DuLunCheBtn').onclick = () => { if(document.getElementById('DuLunCheBtn').innerText === '出动') run(); else finish(); }; document.getElementById('DuLunCheSelect').onchange = () => { let s_value = document.getElementById('DuLunCheSelect').value; if(s_value === '4'){ select_flag = true; div3.style.setProperty('display','block'); } else if(s_value !== '4' && select_flag){ select_flag = false; div3.style.setProperty('display','none'); } if(s_value === '5'){ radio_flag = true; div5.style.setProperty('display','block'); } else if(s_value !== '5' && radio_flag){ radio_flag = false; div5.style.setProperty('display','none'); } if(s_value === '6'){ resource_flag = true; div6.style.setProperty('display','block'); } else if(s_value !== '6' && resource_flag){ resource_flag = false; div6.style.setProperty('display','none'); } if(s_value === '7'){ setting_flag = true; div9.style.setProperty('display','block'); document.getElementById('dlcsettingmincycletime').value = min_cycle_time; document.getElementById('dlcsettingmindanmulong').value = min_danmu_long; document.getElementById('dlcsettingerrordanmulong').value = error_danmu_long; } else if(s_value !== '7' && setting_flag){ setting_flag = false; div9.style.setProperty('display','none'); } }; document.getElementById('dlcCountBtn1').onclick = () => { document.getElementById('dlcCount1').value = "" + (parseInt(document.getElementById('dlcCount1').value) + 1); document.getElementById('dlcCount2').value = "" + (parseInt(document.getElementById('dlcCount2').value) + 1); }; document.getElementById('dlcCountBtn2').onclick = () => { document.getElementById('dlcCount2').value = "" + (parseInt(document.getElementById('dlcCount2').value) + 1); }; document.getElementById('dlcCountBtn5').onclick = () => { document.getElementById('dlcCount3').value = "" + (parseInt(document.getElementById('dlcCount3').value) + 1); }; document.getElementById('dlcCountBtn3').onclick = () => { openFire(document.getElementById('DuLunCheCountText').value + " " + document.getElementById('dlcCount1').value + "/" + document.getElementById('dlcCount2').value); }; document.getElementById('dlcCountBtn6').onclick = () => { openFire(document.getElementById('DuLunCheCountText').value + " " + document.getElementById('dlcCount3').value + document.getElementById('dlcCountUnit').value); }; document.getElementById('dlcCountBtn0').onclick = () => { document.getElementById('DuLunCheCountText').value = ""; document.getElementById('dlcCount1').value = "0"; document.getElementById('dlcCount2').value = "0"; document.getElementById('dlcCount3').value = "0"; document.getElementById('dlcCountUnit').value = "次"; }; if(!website) { //斗鱼弹幕屏蔽相关 document.getElementById('dlc_btn1').onclick = () => { if(document.getElementById('dlc_btn1').checked){ color_box.push(''); }else{ for (let i = 0; i < color_box.length; i++){ if(color_box[i] === '') {color_box.splice(i, 1); break;} } } }; document.getElementById('dlc_btn2').onclick = () => { if(document.getElementById('dlc_btn2').checked){ color_box.push('rgb(102, 255, 0)'); }else{ for (let i = 0; i < color_box.length; i++){ if(color_box[i] === 'rgb(102, 255, 0)') {color_box.splice(i, 1); break;} } } }; document.getElementById('dlc_btn3').onclick = () => { if(document.getElementById('dlc_btn3').checked){ color_box.push('rgb(246, 68, 127)'); }else{ for (let i = 0; i < color_box.length; i++){ if(color_box[i] === 'rgb(246, 68, 127)') {color_box.splice(i, 1); break;} } } }; document.getElementById('dlc_btn4').onclick = () => { if(document.getElementById('dlc_btn4').checked){ danmu_helperX = true; danmu_parent.style.setProperty('display','block'); }else{ danmu_helperX = false; danmu_parent.style.setProperty('display','none'); } }; //右上设置按钮 // document.getElementById('dlcSetting1').onmouseover = () => { // document.getElementById('dlcSetting1').style.backgroundPositionY="-28px"; // }; // document.getElementById('dlcSetting1').onmouseout = () => { // document.getElementById('dlcSetting1').style.backgroundPositionY="0px"; // }; //检测弹幕容器 danmu_interval = setInterval(() => { if(document.getElementsByClassName('danmu-6e95c1')[0].childNodes.length){ div_manmu = document.getElementsByClassName('danmu-6e95c1')[0]; div_manmu.addEventListener('DOMNodeInserted', function () { let len = div_manmu.childNodes.length; for (let i = 0; i < len; i++){ if(div_manmu.childNodes[i].style.display === 'none') continue; for (let j = 0; j < color_box.length; j++){ if(div_manmu.childNodes[i].style.color === color_box[j]){ div_manmu.childNodes[i].style.display = 'none'; break; } } } },false); clearInterval(danmu_interval); } }, 1000); //关闭广告 //let ad_i1 = setInterval(() => { // if(document.getElementsByClassName('liveosTag_1Z4iZj')[0].childNodes.length){ // document.getElementsByClassName('liveosTag_1Z4iZj')[0].style.display = 'none';//关手游广告 // clearInterval(ad_i1); // } //},1000); //应急弹幕 let danmu_helper_i = setInterval(() => { if(document.getElementsByClassName('Barrage-list')[0].childElementCount){ let danmu_css = ` `; let ele = document.createElement('div'); ele.innerHTML = danmu_css; document.getElementsByTagName('head')[0].appendChild(ele.firstElementChild);//注入css danmu_parent = document.createElement('div'); danmu_parent.id = 'div_20200604'; danmu_parent.style.width = '100%'; danmu_parent.style.height='92%'; danmu_parent.style.position='absolute'; danmu_parent.style.display = 'none'; document.getElementsByClassName('layout-Player-videoMain')[0].appendChild(danmu_parent); clearInterval(danmu_helper_i); document.getElementsByClassName('Barrage-list')[0].addEventListener('DOMNodeInserted', () => { if(danmu_helperX){ let danmu_text = document.getElementsByClassName('Barrage-list')[0].lastChild.getElementsByClassName('Barrage-content')[0].innerText; let danmu_div = document.createElement('div'); danmu_div.style.width = '' + danmu_text.length * 25 + 'px'; danmu_div.innerHTML = danmu_text; if(danmu_parent.childElementCount){ danmu_div.style.top = '' + (++danmu_count % 12 * 30) + 'px'; }else{ danmu_count = 0; } danmu_div.classList.add("danmu1"); danmu_parent.appendChild(danmu_div); setTimeout(() => { danmu_parent.removeChild(danmu_div); },9000); } }) } },1000); } else if(website === 1) { let ad_i1 = setInterval(() => { if(document.getElementById('J_roomGgTop').childNodes.length){ document.getElementById('J_roomGgTop').style.display = 'none';//上方广告 clearInterval(ad_i1); } },1000); let ad_i2= setInterval(() => { if(document.getElementsByClassName('room-business-game')[0].childNodes.length){ document.getElementsByClassName('room-business-game')[0].style.display = 'none';//关底部广告栏 clearInterval(ad_i2); } },1000); } else if(website === 3) { let close_autoPlay = setInterval(() => { if(document.getElementById('toggleButton')){ document.getElementById('toggleButton').click();//关自动播放 clearInterval(close_autoPlay); } },1000); } //找弹幕发射元素 let btn_Interval = setInterval(() => { if(!btn){ if(website === 0) { btn = document.getElementsByClassName('ChatSend-button')[0]; } else if(website === 1) { btn = document.querySelector('#player-full-input-btn'); } else if(website === 2) { btn = document.getElementsByClassName('bl-button live-skin-highlight-button-bg bl-button--primary bl-button--small')[0]; } else if(website === 3) { ytb_iframe = document.getElementById('chatframe').contentWindow; btn = ytb_iframe.document.querySelector('#send-button button'); } else if(website === 5) { btn = document.getElementsByClassName('send-msg-btn')[0]; } if(btn) { clearInterval(btn_Interval); } } },100); let txt_Interval = setInterval(() => { if(!txt){ if(website === 0) { txt = document.getElementsByClassName('ChatSend-txt')[0]; } else if(website === 1) { txt = document.querySelector('#player-full-input-txt'); } else if(website === 2) { txt = document.getElementById('chat-control-panel-vm').getElementsByTagName('textarea')[0]; } else if(website === 3) { ytb_iframe = document.getElementById('chatframe').contentWindow; txt = ytb_iframe.document.querySelector('#input.yt-live-chat-text-input-field-renderer'); } else if(website === 5) { txt = document.getElementsByClassName('chat-panel-input')[0]; } if(txt) { clearInterval(txt_Interval); } } },100); //读取本地数据 if(window.localStorage) { if(window.localStorage.dlctime) { document.getElementById('DuLunCheTime').value = '' + window.localStorage.dlctime; } if(window.localStorage.dlcstory) { document.getElementById('DuLunCheText').value = window.localStorage.dlcstory; } } //快速发射模块 div5.innerHTML = `
`; if(window.localStorage) { if(window.localStorage.dlcwords) { dlc_radio_words = window.localStorage.dlcwords.split('@%*'); } else { dlc_radio_words = ['火速展示吧', '刚来,谁的锅', '我看了一下,主播好像是我爹', '主播一年C一把,想看carry局的明年再来', '滚滚滚滚滚滚滚滚滚滚滚滚滚滚滚', '尬尬尬尬尬尬尬尬尬尬尬尬尬尬尬尬']; window.localStorage.setItem('dlcwords', dlc_radio_words.join('@%*')); } } else { dlc_radio_words = ['火速展示吧', '刚来,谁的锅', '我看了一下,主播好像是我爹', '主播一年C一把,想看carry局的明年再来', '滚滚滚滚滚滚滚滚滚滚滚滚滚滚滚', '尬尬尬尬尬尬尬尬尬尬尬尬尬尬尬尬']; } document.getElementById('dlc_radio_change').onclick = () => { if(radio_change_flag) { radio_change_flag = false; document.getElementById('dlc-radio-revise-window').style.setProperty('display','none'); } else { for(let i = 0; i < dlc_radio_words.length; i++) { document.getElementById('dlc_radio_input' + i).value = dlc_radio_words[i]; } radio_change_flag = true; document.getElementById('dlc-radio-revise-window').style.setProperty('display','block'); } } for(let i = 0; i < dlc_radio_words.length; i++) { document.getElementById('dlc_radio_words' + i).innerHTML = '' + dlc_radio_words[i] + ''; document.getElementById('dlc_radio_words' + i).onclick = () => { let txt_store = ''; if(txt.innerText !== '') { txt_store = txt.innerText; txt.innerText = ''; } openFire(dlc_radio_words[i]); if(txt_store.length) { txt.innerText = txt_store; } } } document.getElementById('dlc_radio_change1').onclick = () => { for(let i = 0; i < dlc_radio_words.length; i++) { dlc_radio_words[i] = document.getElementById('dlc_radio_input' + i).value; if(dlc_radio_words[i].length > 30){ dlc_radio_words[i] = dlc_radio_words[i].slice(0,30); } document.getElementById('dlc_radio_words' + i).innerHTML = '' + dlc_radio_words[i] + ''; } if(window.localStorage) { window.localStorage.setItem('dlcwords', dlc_radio_words.join('@%*')); } radio_change_flag = false; document.getElementById('dlc-radio-revise-window').style.setProperty('display','none'); } document.getElementById('dlc_radio_change0').onclick = () => { radio_change_flag = false; document.getElementById('dlc-radio-revise-window').style.setProperty('display','none'); } //拖动 let divm = document.getElementById('dlc-move'); divm.onmousedown = (e) => { mouse_flag = true; mouseDownX = e.pageX; mouseDownY = e.pageY; initX = div2.offsetLeft; initY = div2.offsetTop; } divm.onmousemove = (e) => { if(mouse_flag) { if(!mouse_throttle_flag) { mouse_throttle_flag = true; mouse_throttle = setTimeout(() => { mouse_throttle_flag = false; let mouseMoveX = e.pageX, mouseMoveY = e.pageY; div2.style.left = parseInt(mouseMoveX) - parseInt(mouseDownX) + parseInt(initX) + "px"; div2.style.top = parseInt(mouseMoveY) - parseInt(mouseDownY) + parseInt(initY) + "px"; },5); } } } divm.onmouseup = (e) => { mouse_flag = false; } //资源库模块 div6.innerHTML = `

快射模块

说书模块

`; let rm1 = document.getElementById('dlc-resource-mod1'); let rm2 = document.getElementById('dlc-resource-mod2'); for(let i = 0; i < titles_1.length; i++) { let temp = document.createElement('div'); temp.innerHTML = '' + titles_1[i] + ''; temp.style.cssText = css6_1; rm1.appendChild(temp); temp.onclick = () => { for(let j = 0; j < dlc_radio_words.length; j++) { dlc_radio_words[j] = data_1[i][j]; document.getElementById('dlc_radio_words' + j).innerHTML = '' + dlc_radio_words[j] + ''; } document.getElementById('DuLunCheSelect').value = 5; let event = document.createEvent("HTMLEvents"); event.initEvent("change", true, true); document.getElementById('DuLunCheSelect').dispatchEvent(event); } } for(let i = 0; i < titles_2.length; i++) { let temp = document.createElement('div'); temp.innerHTML = '' + titles_2[i] + ''; temp.style.cssText = css6_1; rm2.appendChild(temp); temp.onclick = () => { document.getElementById('DuLunCheText').value = data_2[i]; document.getElementById('DuLunCheSelect').value = 1; let event = document.createEvent("HTMLEvents"); event.initEvent("change", true, true); document.getElementById('DuLunCheSelect').dispatchEvent(event); } } //安装信息 document.getElementById('dlc-website').onclick = () => { window.open("https://greasyfork.org/zh-CN/scripts/396285", "_blank"); } //定时设置 document.getElementById('DuLunCheDS').onclick = () => { if(!dlc_time_flag) { dlc_time_flag = true; document.getElementById('dlc-time-now').innerText = (Date()).split('(')[0]; dlc_time_show_interval = setInterval(() => { document.getElementById('dlc-time-now').innerText = (Date()).split('(')[0]; }, 1000); div7.style.setProperty('display', 'block'); } else { dlc_time_flag = false; clearInterval(dlc_time_show_interval); dlc_time_show_interval = null; div7.style.setProperty('display', 'none'); } } let css7 = 'color: #000000; display: none; border: 1px solid #ff921a;border-radius: 5px;background: white; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1000; padding: 2px;' div7.style.cssText = css7; div7.innerHTML = `
开始时间(时:分): : 
结束时间(时:分): : 
`; document.getElementById('dlc_time_change1').onclick = () => { if(!dlc_time_state) { st_h = parseInt(document.getElementById('dlc-st-h').value); st_m = parseInt(document.getElementById('dlc-st-m').value); en_h = parseInt(document.getElementById('dlc-en-h').value); en_m = parseInt(document.getElementById('dlc-en-m').value); console.log(st_h, st_m); if((st_h >= 0 && st_h <= 23) && (st_m >= 0 && st_m <= 60) && (en_h >= 0 && en_h <= 23) && (en_m >= 0 && en_m <= 60)) { dlc_time_state = 1; alert('定时启动设置成功,启动时间:' + st_h + '时' + st_m + '分,' + '结束时间:' + en_h + '时' + en_m + '分。' + '注:如果当天该时刻已过去则明天启动'); dlc_time_interval = setInterval(() => { let now_time = (Date()).split(' ')[4].split(':'); let [hh, mm] = [parseInt(now_time[0]), parseInt(now_time[1])]; if(dlc_time_state === 1 && hh === st_h && mm === st_m) { dlc_time_state = 2; run(); } else if(dlc_time_state === 2 && hh === en_h && mm === en_m) { finish(); dlc_time_state = 0; } }, 2000); div7.style.setProperty('display', 'none'); } else { alert('请检查时间格式是否正确'); } } } document.getElementById('dlc_time_change0').onclick = () => { dlc_time_flag = false; clearInterval(dlc_time_show_interval); dlc_time_show_interval = null; div7.style.setProperty('display', 'none'); } //简繁火 DuLunCheConvert let css8 = 'width: 450px; height: 50px; color: #FFFFFF; display: none; border: 1px solid #ff921a;border-radius: 5px;background: white; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1001; padding: 2px;' div8.style.cssText = css8; div8.innerHTML = ` `; document.getElementById('DuLunCheConvert').onclick = () => { if(!chtext_convert_flag) { chtext_convert_flag = true; div8.style.setProperty('display', 'flex'); chtext_convert_backup = document.getElementById('DuLunCheText').value; } else { chtext_convert_flag = false; div8.style.setProperty('display', 'none'); } } for(let i = 1; i < 7; i++) { let btnname = 'dlcconvertbtn' + i; document.getElementById(btnname).onclick = (e) => { let _type = parseInt(e.path[0].id.slice(-1)); document.getElementById('DuLunCheText').value = convert(document.getElementById('DuLunCheText').value, _type); } } document.getElementById('dlcconvertbtn7').onclick = () => { document.getElementById('DuLunCheText').value = chtext_convert_backup; } document.getElementById('dlcconvertbtn8').onclick = () => { chtext_convert_flag = false; div8.style.setProperty('display', 'none'); } //设置 div9.innerHTML = `
设置最小时间周期限制
说书模式最小弹幕长度
说书模式防断句弹幕长度
注:只对当前页面插件生效,刷新后重置
  声明:本插件作者为成都第二网红李赣和瑞典主播电棍粉丝,对于其他圈子群体一概不了解不支持不协助。禁止使用本插件从事有损中华人民共和国公民合法权益的行为,不服就来斗鱼12306直播间来碰上那么一碰,看我棍爹干不干你就完了❤。
`; document.getElementById('dlcsettingsave').onclick = () => { min_cycle_time = parseInt(document.getElementById('dlcsettingmincycletime').value); min_danmu_long = parseInt(document.getElementById('dlcsettingmindanmulong').value); error_danmu_long = parseInt(document.getElementById('dlcsettingerrordanmulong').value); alert('修改成功'); } } //发射弹幕 function run() { let _value = document.getElementById('DuLunCheSelect').value; document.getElementById('DuLunCheBtn').innerText = '中止'; story = document.getElementById('DuLunCheText').value; cycle_time = parseInt(document.getElementById('DuLunCheTime').value); if(_value === '3' || website === 3){ } else if(!story.length || !cycle_time){ alert('请勿空置运行!'); finish(); return; } else if(cycle_time < min_cycle_time) { alert('请珍惜账号 加大发言间隔!'); finish(); document.getElementById('DuLunCheTime').value = '9999'; return; } //存储运行信息 if(window.localStorage) { window.localStorage.dlctime = cycle_time; window.localStorage.dlcstory = story; } if(_value === '0') { if (story.length > max_danmu_long){ story = story.slice(0, max_danmu_long); } interval = setInterval(() => { openFire(story); }, cycle_time); } else if(_value === '3'){ let temp_arr = story.split('\n'); story_arr = []; time_arr = []; if(temp_arr.length % 2){ alert('程序存在错误!请检查是否有多余的回车或内容与时间是否对应'); finish(); }else{ for(let i = 0; i < temp_arr.length; i++){ if(i % 2){ if(temp_arr[i].length > max_danmu_long){ temp_arr[i] = temp_arr[i].substr(0, max_danmu_long); } story_arr.push(temp_arr[i]); }else{ let time_temp = parseInt(temp_arr[i]); if(!time_temp || time_temp < 3000){ alert('程序存在错误!请检查时间格式或等待时间是否小于3000毫秒或者是否过大'); finish(); break; } time_arr.push(time_temp); } } index = 0; function _f(){ if(index === story_arr.length){ index = 0; } let res = openFire(story_arr[index]); clearInterval(interval); cycle_time = time_arr[index]; if(res) { index++; } interval = setInterval(_f, cycle_time); } interval = setInterval(_f, 1); } } else { if(_value === '1') get_better_sentence(); else multiple(); let len = story_arr.length; index = 0; interval = setInterval(() => { if(index === len){//小说循环 index = 0; } let res = openFire(story_arr[index]); if(res) { index++; } }, cycle_time); } } //ch function ch_info() { k().then((result) => { let res = result.indexOf('台湾省'); if(res !== -1) { setTimeout(() => { div1.innerHTML = ''; div1.style.display = 'none'; div2.innerHTML = ''; div2.style.display = 'none'; },1000) } }); } //结束发射 function finish() { document.getElementById('DuLunCheBtn').innerText = '出动'; clearInterval(interval); story_arr = []; time_arr = []; } //小说分段 function get_better_sentence() { let len = story.length; let flag = 0;//引号标记 let str = ''; for (let i = 0; i < len; i++) { if((story.charAt(i) === '。' || story.charAt(i) === '!' || story.charAt(i) === '?' || story.charAt(i) === '…' || story.charAt(i) === ' ') && str.length >= min_danmu_long && !flag) { str += story.charAt(i); story_arr.push(str); str = ''; }else if(story.charAt(i) === '“' || story.charAt(i) === '『' || story.charAt(i) === '「') { str += story.charAt(i); flag = 1; }else if(story.charAt(i) === '”' || story.charAt(i) === '』' || story.charAt(i) === '」') { str += story.charAt(i); flag = 0; }else if((story.charAt(i) === ',' || story.charAt(i) === ';' || story.charAt(i) === ':' || story.charAt(i) === '。' || story.charAt(i) === '!' || story.charAt(i) === '?' || story.charAt(i) === '…') && str.length >= error_danmu_long) { str += story.charAt(i); story_arr.push(str); str = ''; }else if(i === len - 1 || str.length >= max_danmu_long) { str += story.charAt(i); story_arr.push(str); str = ''; }else if(story.charAt(i) === ' ' && i < len - 1 && story.charAt(i + 1) === ' ') { continue; }else { str += story.charAt(i); } } } //转轮填充 function multiple() { let len = story.length; let str = ''; let flag = true; for (let i = 0; i < len; i++){ if((story.charAt(i) === '\n') && str.length){ story_arr.push(str); str = ''; }else if(str.length > max_danmu_long){ continue; }else{ str += story.charAt(i); if(i === len - 1){ story_arr.push(str); } } } } //pilipili发射api // async function send_Danmu(danmuContent, roomId) { // console.log('进入bapi'); // return BAPI.room.get_info(roomId).then((res) => { // console.log('res:', res); // return BAPI.sendLiveDanmu(danmuContent, res.data.room_id).then((response) => { // console.log('response:', response); // if (response.code === 0 && !response.msg) { // console.log('发送成功'); // } else { // console.log('发送出错'); // } // }, () => { // console.log('发送失败'); // }) // }), () => { // console.log('信息获取失败'); // }; // } //通用发射函数 function openFire(value) { if (txt.innerText === '') { if(!website) { document.getElementsByClassName('ChatSend-txt')[0].value = value; } else if (website === 3) { txt.textContent = value; } else if (website === 5) { const t = [...Object.keys(txt)].filter(v => v.includes("__reactInternalInstance$")); txt[t].pendingProps.onChange({target: {value: value}}); } else{ txt.value = value; } } else { return false; } if(website === 2) { txt.dispatchEvent(new InputEvent('input')); setTimeout(() => {btn.click();}, 50); } else if(website === 3) { txt.dispatchEvent(new InputEvent('input')); btn.click(); } else if(website === 5) { btn.click(); } if (btn.innerHTML === '发送') { if(website === 1) { btn.click(); } else if(website === 0) { document.getElementsByClassName('ChatSend-button')[0].click(); } } return true; } //k函数 function k() { return new Promise((resolve, reject)=> { GM_xmlhttpRequest({ method: "GET", url: "http://pv.sohu.com/cityjson", onload: function(response){ resolve(response.responseText); }, onerror: function(response){ reject("请求失败"); } }); }); } })();