let script = document.createElement("script");
script.innerHTML = `
let flag = 1;
let timer;
let i=0;
let speed=10000;
let content=null;
function fireKeyEvent(el, evtType, keyCode) {
var doc = el.ownerDocument,
win = doc.defaultView || doc.parentWindow,
evtObj;
if (doc.createEvent) {
if (win.KeyEvent) {
evtObj = doc.createEvent("KeyEvents");
evtObj.initKeyEvent(evtType, true, true, win, false, false, false, false, keyCode, 0);
}
else {
evtObj = doc.createEvent("UIEvents");
Object.defineProperty(evtObj, "keyCode", {
get: function () { return this.keyCodeVal; }
});
Object.defineProperty(evtObj, "which", {
evtObj.initUIEvent(evtType, true, true, win, 1);
evtObj.keyCodeVal = keyCode;
if (evtObj.keyCode !== keyCode) {
console.log("keyCode " + evtObj.keyCode + " 和 (" + evtObj.which + ") 不匹配");
el.dispatchEvent(evtObj);
else if (doc.createEventObject) {
evtObj = doc.createEventObject();
evtObj.keyCode = keyCode;
el.fireEvent("on" + evtType, evtObj);
window.οnkeydοwn=ev => {
if (ev.keyCode === 106) {
if (++flag % 2 === 0) {
new Promise((resolve, reject) => {
content=window.prompt("請輸入自動傳送的彈幕內容【請用英文逗號分割每次需要傳送的一句話】")
resolve(content)
}).then(r => {
const spam = () => {
timer = setInterval(() => {
const target = document.querySelector("#pub_msg_input")
let texts=r.split(",");
fireKeyEvent(target, "keydown", 13)
if (texts.length == i) {
i = 0;
} else {
target.value = texts[i]
i++;
document.querySelector("#msg_send_bt").click()
}, speed);
spam()
alert("已關閉")
clearInterval(timer)
}`
document.querySelector("body").append(script);
複製上面程式碼
開啟web瀏覽器進入虎牙網站登陸自己的賬號
按F12或者滑鼠右鍵審查元素
在到console下面複製上述程式碼再按Enter鍵
按*鍵
let script = document.createElement("script");
script.innerHTML = `
let flag = 1;
let timer;
let i=0;
let speed=10000;
let content=null;
function fireKeyEvent(el, evtType, keyCode) {
var doc = el.ownerDocument,
win = doc.defaultView || doc.parentWindow,
evtObj;
if (doc.createEvent) {
if (win.KeyEvent) {
evtObj = doc.createEvent("KeyEvents");
evtObj.initKeyEvent(evtType, true, true, win, false, false, false, false, keyCode, 0);
}
else {
evtObj = doc.createEvent("UIEvents");
Object.defineProperty(evtObj, "keyCode", {
get: function () { return this.keyCodeVal; }
});
Object.defineProperty(evtObj, "which", {
get: function () { return this.keyCodeVal; }
});
evtObj.initUIEvent(evtType, true, true, win, 1);
evtObj.keyCodeVal = keyCode;
if (evtObj.keyCode !== keyCode) {
console.log("keyCode " + evtObj.keyCode + " 和 (" + evtObj.which + ") 不匹配");
}
}
el.dispatchEvent(evtObj);
}
else if (doc.createEventObject) {
evtObj = doc.createEventObject();
evtObj.keyCode = keyCode;
el.fireEvent("on" + evtType, evtObj);
}
}
window.οnkeydοwn=ev => {
if (ev.keyCode === 106) {
if (++flag % 2 === 0) {
new Promise((resolve, reject) => {
content=window.prompt("請輸入自動傳送的彈幕內容【請用英文逗號分割每次需要傳送的一句話】")
resolve(content)
}
}).then(r => {
const spam = () => {
timer = setInterval(() => {
const target = document.querySelector("#pub_msg_input")
let texts=r.split(",");
fireKeyEvent(target, "keydown", 13)
if (texts.length == i) {
i = 0;
} else {
target.value = texts[i]
i++;
}
document.querySelector("#msg_send_bt").click()
}, speed);
}
spam()
});
} else {
alert("已關閉")
clearInterval(timer)
}
}
}`
document.querySelector("body").append(script);
複製上面程式碼
開啟web瀏覽器進入虎牙網站登陸自己的賬號
按F12或者滑鼠右鍵審查元素
在到console下面複製上述程式碼再按Enter鍵
按*鍵