Greasy Fork is available in English.
啊B或油管打尻,需要用户已登录。若有滥用等问题概不负责,诶嘿。顺便关注一下小东人鱼和noworld吧~
当前为
// ==UserScript==
// @name B站油管简易打尻装置
// @namespace http://tampermonkey.net/
// @version 0.3
// @description 啊B或油管打尻,需要用户已登录。若有滥用等问题概不负责,诶嘿。顺便关注一下小东人鱼和noworld吧~
// @author 太陽闇の力
// @include /https?:\/\/live\.bilibili\.com\/(blanc\/)?\d+\??.*/
// @match https://www.youtube.com/live_chat*
// @grant none
// @license MIT
// ==/UserScript==
//界面参考自小东人鱼午安社五更耗纸 https://github.com/gokoururi-git/gachihelper/
//找到代码中let countdown = "220"; let intervaltime = "6";这两句可以改开局的倒计时时间和发送间隔时间(油管的发送间隔在let intervaltime = "6";下面改)。
//interval.min、interval.max、interval.step分别是滑动条的最小值、最大值和滑动间隔。可以找到这几句进行更改。
//五秒内同一句打call的话,会显示发送频率太快而无法发送成功。建议写多几句不一样的。
/*如果要添加默认打call语句,可以在textArea.value=``;这句的``里面添加内容,比如:
textArea=`\\小东/
\\noir/
♪小东♪
♪noir♪`;
代码里两个\相当于一个\
*/
window.onload = (windows) => {
let waitTime = 1;//等待1秒,如果加载比较慢的话,不等待可能获取不到元素。
const main = () => {
try {
//-----------配置区-------------
//0默认收起,1默认展开
let isunfold = 0;
let unfold = ["展开","收起"];
//输入框选择符
const inputSelector = 'textarea';
//发送按钮选择符
const sendSelector =
'.bl-button';
const biliTextArea = window.document.querySelector(inputSelector)||window.document.querySelector("#input").querySelector("#input");
if (!biliTextArea) {
window.alert('打尻:找不到输入框');
return;
}
const biliTextSender = window.document.querySelector(sendSelector)||window.document.querySelector("#send-button").querySelector("#button");
if (!biliTextSender) {
window.alert('打尻:找不到发送按钮');
return;
}
const callDealler = (call) => {
let tempcallResult = [];
call = call.trim();
call = call.replace(/ /g, '');
call = call.replace(/ /g, '');
call = call.replace(/\n{2,}/g, '\n');
tempcallResult = call.split('\n');
return tempcallResult;
}
let countdown = "220";
let intervaltime = "6";
if(window.location.href.indexOf("live_chat")!=-1){//如果在油管的话设置初始20,油管的初始发送间隔可以在这里改
intervaltime="20";
}
let callResult = [];
let currIndex = 0;
let t = null;
let ct = null;
const inputEvent = document.createEvent("Event");
inputEvent.initEvent("input");
const next = function() {
if (currIndex == callResult.length) currIndex = 0;
if(window.location.href.indexOf("live_chat")!=-1){
biliTextArea.innerText = callResult[currIndex++];
}else{
biliTextArea.value = callResult[currIndex++];
}
biliTextArea.dispatchEvent(inputEvent);
biliTextSender.click();
}
const init = function() {
currIndex = 0;
if(window.location.href.indexOf("live_chat")!=-1){
biliTextArea.innerText = callResult[currIndex++];
}else{
biliTextArea.value = callResult[currIndex++];
}
biliTextArea.dispatchEvent(inputEvent);
biliTextSender.click();
t = setInterval(next, interval.value * 1000);
}
// ------------------GUI设计开始---------------
// 总容器
const container = window.document.createElement('div');
container.style.width = '354px';
container.style.position = 'fixed';
container.style.bottom = '5px';
container.style.left = '5px';
container.style.zIndex = '999';
container.style.boxSizing = 'border-box';
// 工具名称
const topTool = window.document.createElement('div');
topTool.innerText = 'call';
topTool.style.textAlign = 'center';
topTool.style.lineHeight = '20px';
topTool.style.height = '20px';
topTool.style.width = '100%';
topTool.style.color = 'rgb(210,143,166)';
topTool.style.fontSize = '14px';
// 最小化按钮
const collapseButton = window.document.createElement('button');
collapseButton.innerText = unfold[isunfold];
collapseButton.style.float = 'right';
collapseButton.style.width = '40px';
collapseButton.style.height = '20px';
collapseButton.style.border = 'none';
collapseButton.style.cursor = 'pointer';
collapseButton.style.backgroundColor = '#1890ff';
collapseButton.style.borderRadius = '0';
collapseButton.style.color = '#ffffff';
// 主窗口
const mainWindow = window.document.createElement('div');
if(isunfold==0){
mainWindow.style.display = "none";
}
mainWindow.style.width = '100%';
mainWindow.style.backgroundColor = 'rgba(220, 192, 221, .5)';
mainWindow.style.padding = '10px';
mainWindow.style.boxSizing = 'border-box';
// call框
const textArea = window.document.createElement('textarea');
textArea.value=``;//如果有\的话,需要写成\\
textArea.style.boxSizing = 'border-box';
textArea.style.width = '100%';
textArea.style.height = '50px';
textArea.style.resize = 'none';
textArea.style.outline = 'none';
textArea.style.background = 'rgba(255,255,255,.5)';
// 按钮区容器
const buttonArea = window.document.createElement('div');
buttonArea.style.width = '100%';
buttonArea.style.boxSizing = 'border-box';
buttonArea.style.height = '30px';
buttonArea.style.display = 'flex';
// 开始按钮
const goButton = window.document.createElement('button');
goButton.innerText = '开始';
goButton.style.width = 'max-content';
goButton.style.height = '28px';
goButton.style.padding = '0 5px';
goButton.style.marginLeft = '5px';
// 发送间隔提示文本
const intervalLabel = window.document.createElement('div');
intervalLabel.innerText = '发送间隔: '
intervalLabel.style.width = 'max-content';
intervalLabel.style.height = '28px';
intervalLabel.style.lineHeight = '28px';
// 选择延迟
const interval = window.document.createElement('input');
interval.type = "range";
interval.step = "0.1";
interval.min = "2";
interval.value = intervaltime;
interval.max = "30";
interval.style.width = 'max-content';
interval.style.padding = '0 5px';
interval.style.height = '28px';
interval.style.marginLeft = '5px';
// 秒数提示文本
const timeLabel = window.document.createElement('div');
timeLabel.innerText = intervaltime;
timeLabel.style.width = '24px';
timeLabel.style.height = '28px';
timeLabel.style.lineHeight = '28px';
// 秒数提示文本
const secondLabel = window.document.createElement('div');
secondLabel.innerText = '秒';
secondLabel.style.width = 'max-content';
secondLabel.style.height = '28px';
secondLabel.style.lineHeight = '28px';
// 倒计时
const countDownButton = window.document.createElement('button');
countDownButton.setAttribute("contenteditable", "true");
countDownButton.innerText = countdown;
countDownButton.style.width = '50px';
countDownButton.style.padding = '0 5px';
countDownButton.style.height = '28px';
countDownButton.style.marginLeft = '5px';
// 组装
topTool.appendChild(collapseButton);
container.appendChild(topTool);
mainWindow.appendChild(textArea);
buttonArea.appendChild(intervalLabel);
buttonArea.appendChild(interval);
buttonArea.appendChild(timeLabel);
buttonArea.appendChild(secondLabel);
buttonArea.appendChild(goButton);
buttonArea.appendChild(countDownButton);
mainWindow.appendChild(buttonArea);
container.appendChild(mainWindow);
window.document.body.appendChild(container);
// 显示逻辑控制
collapseButton.addEventListener('click', () => {
if (collapseButton.innerText === '收起') {
mainWindow.style.display = 'none';
collapseButton.innerText = '展开';
return;
}
if (collapseButton.innerText === '展开') {
mainWindow.style.display = 'block';
collapseButton.innerText = '收起';
return;
}
}, false);
//显示滑动条数字
interval.onchange = function() {
timeLabel.innerText = interval.value;
}
//-------------------gui设计结束------------------
const countdownfunc = function() {
if (countDownButton.innerText == 0) {
clearInterval(t);
clearInterval(ct);
goButton.innerText = '开始';
countDownButton.innerText = countdown;
countDownButton.setAttribute("contenteditable", "true");
} else {
countDownButton.innerText -= 1;
}
}
goButton.addEventListener('click', () => {
if (goButton.innerText == '暂停') {
clearInterval(t);
clearInterval(ct);
goButton.innerText = '开始';
countDownButton.innerText = countdown;
countDownButton.setAttribute("contenteditable", "true");
return;
}
const value = textArea.value;
if (value.trim() === '') {
window.alert('打尻:您还没有输入call语句');
return;
}
callResult = callDealler(value);
init();
goButton.innerText = '暂停';
countDownButton.setAttribute("contenteditable", "false");
if (!isNaN(parseFloat(countDownButton.innerText))) {
countdown = countDownButton.innerText;
}
ct = setInterval(countdownfunc, 1000);
}, false);
} catch (e) {
if(window.confirm('打尻:发生未知错误\n可能是在加载中无法获取元素\n' + e+"\n是否重新尝试打尻?")){
setTimeout(main,1000*(waitTime+3));
};
}
}
setTimeout(main, 1000 * waitTime);
};