// ==UserScript==
// @name 凡人弹幕按钮
// @version 0.51循环攻击
// @description 直播间界面按下键盘F12,点击控制台或Console选项。将全部代码复制粘贴并回车开始使用。
// @author 今日天空晴
// @match https://live.bilibili.com/*
// ==/UserScript==
'use strict';
var zengjia=document.getElementsByTagName("div")[2];
zengjia.innerHTML+=//add button
"<div id='zhan'>"
+"<button id='zhankai' style='cursor:pointer;float:right;background:#f9f;border-radius:30px;padding:20px;'>展开</button>"
+"</div>"
+"<div id='fanrengongji' style='width:900px;'>"
+"<div>"
+"<button id='shang' style='cursor:pointer;padding:10px 20px;'>上</button>"
+"弹幕间隔(最低1秒)<input id='interval' value='1' style='text-align:center; width:50px;'/>"
+"以空格分开不同弹幕<input id='xunhuan' value='雷 招雷 雷击 唤雷 召雷 召唤雷劫 招唤雷劫' style='width:300px;'>"
+"<button id='kuanglei' style='cursor:pointer;background:yellow;'>循环弹幕</button>"
+"<button id='tingzhi' style='cursor:pointer;'>循环停止</button>"
+"<label id='shouqi' style='float:right;cursor:pointer;background:none;padding:5px;'>X</label>"
+"<br><button id='zuo' style='cursor:pointer;padding:10px 20px;'> 左 </button>"
+"<button id='you' style='cursor:pointer;padding:10px 20px;'> 右 </button>"
+"<button id='likai' style='cursor:pointer;'>离开座位</button>"
+"<button id='chakan' style='cursor:pointer;background:orange;'>查看背包</button>"
+"<button id='chujia' style='cursor:pointer;background:yellow;'>拍卖出价</button>"
+" 输入攻击座位号<input id='seat' value='' style='text-align:center; width:50px;'/>"
+"<button id='gongji' style='cursor:pointer;background:yellow;'>循环攻击</button>"
+"<label id='tishi' style='position:relative;left:100px;color:red;font-size:14px;'></label>"
+"<br>"
+"<button id='xia' style='cursor:pointer;padding:10px 20px;'>下</button>"
+"一次性聊天弹幕(不用中断循环)<input id='baoliu' type='checkbox' checked='checked'/>保留文字"
+"<input id='liaotian' value='' style='width:230px;'/>"
+"<button id='songchu' style='cursor:pointer;background:yellow;'>一次弹幕</button>"
+"</div>"
+"<div id='buttondown' style='float:left;'>"
+"</div>"
+"<div id='divdhz' style='display:none;'></div>"
+"<div id='divxthl' style='display:none;'></div>"
+"<div id='divxysj' style='display:none;'></div>"
+"<div id='divylfj' style='display:none;'></div>"
+"</div>"
+"<style type='text/css'>"
+"#fanrengongji{float:left; border:2px solid green; z-index:999; top:1px; background:#cfc; padding:5px; position:absolute;}"
+"#zhan{display:block; float:left; z-index:998; top:1px; padding:5px; position:absolute;}"
+"#fanrengongji button{border-radius:30px;padding:10px;}</style>";
var myVar = null;
var interval = null;
function rundanmu(a) {//循环弹幕
str=null;
interval=document.getElementById("interval").value;//间隔秒数
if (interval <1){
interval = 1;
}
if(myVar!=null){
clearInterval(myVar);
myVar=null;
}
if (a=="gonji"){
pn=document.getElementById("seat").value;
if (pn != null && pn != ""){
str = pn+"打 "+pn+"攻 "+pn+"攻击 "+pn+"煞气"
+" 打"+pn+" 攻"+pn+" 攻击"+pn+" 煞气"+pn
;}
} else if (a=="kuanglei"){
str=document.getElementById("xunhuan").value;
} else {}
myVar = setInterval(function(){ myTimer(str) }, 1000*interval);
}
var pn = null;
var count = 0;
var str= null;
function myTimer(str) {//执行
if (str != null && str != ""){
var strList = str.split(' ');
var Max = strList.length;
var danmu = document.querySelectorAll("textarea.chat-input.border-box")[0];
var evt = new InputEvent('input', {
inputType: 'insertText',
data: 'insertText',
dataTransfer: null,
isComposing: false
});
if(Max!=1){
danmu.value = strList[count];
}else{
danmu.value = str;
}
danmu.dispatchEvent(evt);
setTimeout(() => {
document.querySelectorAll("button.bl-button.live-skin-button-text")[0].click();
}, 100);
count++;
if(count >= Max){
count = 0;
}
}
}
function myStopFunction() {
clearInterval(myVar);
myVar=null;
}
function danmu1(str) {//一次性弹幕
var danmu = danmu=document.querySelectorAll("textarea.chat-input.border-box")[0];
var evt = new InputEvent('input', {
inputType: 'insertText',
data: 'insertText',
dataTransfer: null,
isComposing: false
});
danmu.value = str;
danmu.dispatchEvent(evt);
document.querySelectorAll("button.bl-button.live-skin-button-text")[0].click();
}
const buttondown=document.getElementById("buttondown");
function downbutton(bid,bgcolor,bname){
buttondown.innerHTML+="<button id="+bid+" style='cursor:pointer;background:"+bgcolor+";'>"+bname+"</button>";
}
function downlabel(bid,bgcolor,bname){
buttondown.innerHTML+="<label id="+bid+" style='cursor:pointer;padding:10px;background:"+bgcolor+";'>"+bname+"</label>";
}
const divdhz=document.getElementById("divdhz");
const divxthl=document.getElementById("divxthl");
const divxysj=document.getElementById("divxysj");
const divylfj=document.getElementById("divylfj");
function downdhz(bid,bgcolor,bname){
divdhz.innerHTML+="<button id="+bid+" style='cursor:pointer;background:"+bgcolor+";'>"+bname+"</button>";
}
function downxthl(bid,bgcolor,bname){
divxthl.innerHTML+="<button id="+bid+" style='cursor:pointer;background:"+bgcolor+";'>"+bname+"</button>";
}
function downxysj(bid,bgcolor,bname){
divxysj.innerHTML+="<button id="+bid+" style='cursor:pointer;background:"+bgcolor+";'>"+bname+"</button>";
}
function downylfj(bid,bgcolor,bname){
divylfj.innerHTML+="<button id="+bid+" style='cursor:pointer;background:"+bgcolor+";'>"+bname+"</button>";
}
downlabel("dhz","none","东皇钟>>");
downlabel("xthl","none","先天葫芦>>");
downlabel("xysj","none","轩辕神剑>>");
downlabel("ylfj","none","英灵飞剑>>");
downbutton("sjcb","#6af","养成翅膀");
downbutton("zzfb","#6af","制作法宝");
downdhz("ckdhz","orange","查看东皇钟");
downdhz("sjdhz","#6af","升级东皇钟");
downdhz("xhdhz","gray","销毁东皇钟");
downxthl("ckxthl","orange","查看先天葫芦");
downxthl("sjxthl","#6af","升级先天葫芦");
downxthl("xhxthl","gray","销毁先天葫芦");
downxysj("ckxysj","orange","查看轩辕神剑");
downxysj("sjxysj","#6af","升级轩辕神剑");
downxysj("xhxysj","gray","销毁轩辕神剑");
downylfj("ckylfj","orange","查看英灵飞剑");
downylfj("sjylfj","#6af","升级英灵飞剑");
downylfj("xhylfj","gray","销毁英灵飞剑");
function myevent() {
var gongi=document.getElementById("gongji");
gongi.addEventListener("click", function(){
rundanmu("gonji");
document.getElementById("tishi").innerHTML="攻击循环!....... ";
});
var kuanglei=document.getElementById("kuanglei");
kuanglei.addEventListener("click", function(){
rundanmu("kuanglei");
document.getElementById("tishi").innerHTML="循环弹幕!....... ";
});
var tingzhi=document.getElementById("tingzhi");
tingzhi.addEventListener("click", function(){
myStopFunction();
document.getElementById("tishi").innerHTML="停止循环...................... ";
});
var likai=document.getElementById("likai");
likai.addEventListener("click", function(){
danmu1("离开");
});
var chakan=document.getElementById("chakan");
chakan.addEventListener("click", function(){
danmu1("查看");
});
var chujia=document.getElementById("chujia");
chujia.addEventListener("click", function(){
danmu1("出价");
});
var fanren=document.getElementById("fanrengongji");
var zhan=document.getElementById("zhan");
var shouqi=document.getElementById("shouqi");
shouqi.addEventListener("click", function(){
fanren.style.display="none";
});
var zhankai=document.getElementById("zhankai");
zhankai.addEventListener("click", function(){
fanren.style.display="block";
});
const dhz=document.getElementById("dhz");
const xthl=document.getElementById("xthl");
const xysj=document.getElementById("xysj");
const ylfj=document.getElementById("ylfj");
dhz.addEventListener("click", function(){
divdhz.style.display="inline";
divxthl.style.display=divxysj.style.display=divylfj.style.display="none";
});
xthl.addEventListener("click", function(){
divxthl.style.display="inline";
divdhz.style.display=divxysj.style.display=divylfj.style.display="none";
});
xysj.addEventListener("click", function(){
divxysj.style.display="inline";
divxthl.style.display=divdhz.style.display=divylfj.style.display="none";
});
ylfj.addEventListener("click", function(){
divylfj.style.display="inline";
divxthl.style.display=divxysj.style.display=divdhz.style.display="none";
});
var liaotian=document.getElementById("liaotian");
liaotian.addEventListener("keypress", function(event){
if(event.key==="Enter"){
danmu1(liaotian.value);
if(document.getElementById("baoliu").checked == false){
liaotian.value="";
}
}
});
const songchu=document.getElementById("songchu");
songchu.addEventListener("click", function(){
const liaotian=document.getElementById("liaotian");
danmu1(liaotian.value);
if(document.getElementById("baoliu").checked == false){
liaotian.value="";
}
});
const seat=document.getElementById("seat");
seat.addEventListener("click", function(){
seat.value="";
});
const interval=document.getElementById("interval");
interval.addEventListener("click", function(){
interval.value="";
});
document.getElementById("shang").onclick=function(){danmu1("上");};
document.getElementById("xia").onclick=function(){danmu1("下");};
document.getElementById("zuo").onclick=function(){danmu1("左");};
document.getElementById("you").onclick=function(){danmu1("右");};
document.getElementById("ckdhz").onclick=function(){danmu1("查看东皇钟");};
document.getElementById("ckxthl").onclick=function(){danmu1("查看先天葫芦");};
document.getElementById("ckxysj").onclick=function(){danmu1("查看轩辕神剑");};
document.getElementById("ckylfj").onclick=function(){danmu1("查看英灵飞剑");};
document.getElementById("sjcb").onclick=function(){danmu1("养成翅膀");};
document.getElementById("sjdhz").onclick=function(){danmu1("升级东皇钟");};
document.getElementById("sjxthl").onclick=function(){danmu1("升级先天葫芦");};
document.getElementById("sjxysj").onclick=function(){danmu1("升级轩辕神剑");};
document.getElementById("sjylfj").onclick=function(){danmu1("升级英灵飞剑");};
document.getElementById("zzfb").onclick=function(){danmu1("制作法宝");};
document.getElementById("xhdhz").onclick=function(){danmu1("销毁东皇钟");};
document.getElementById("xhxthl").onclick=function(){danmu1("销毁先天葫芦");};
document.getElementById("xhxysj").onclick=function(){danmu1("销毁轩辕神剑");};
document.getElementById("xhylfj").onclick=function(){danmu1("销毁英灵飞剑");};
}
myevent();
熊饱超可耐呐!♥