b-live-random-send-test

定时从设置的字幕中随机取出一条在B站直播间发送,需先登录B站账号

Stan na 24-07-2022. Zobacz najnowsza wersja.

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greasyfork.org/scripts/447936/1073710/b-live-random-send-test.js

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @author          Gamyou
// @version         1.2.5
// @note            22-07-24 1.2.5 增加分组启用按钮,并优化设置面板样式
// @note            22-07-23 1.2.4 修复弹幕分组数据都为空时,旧数据重复合并的BUG
// @note            22-07-16 1.2.3 修复设置弹幕时旧(初始)数据没有清空的BUG
// @note            22-06-24 1.2.2 优化部分代码
// @note            22-06-20 1.2.1 修复定时停止不能再开始的BUG
// @note            22-06-19 1.2.0 添加弹幕设置功能
// ==/UserScript==


(function () {
    window.autoSendDanmuModuleLoaded = false;
    let source = {
        version: 3,
        random: true,
        data1: { available: true, values: ['绿豆', '红豆', '黄豆', '蓝猫'] },
        data2: { available: true, values: ['红', '接天莲叶无穷碧,映日荷花别样红。'] },
        data3: { available: true, values: ['黄', '儿童急走追黄蝶,飞入菜花无处寻。'] },
        data4: { available: true, values: ['蓝', '沧海月明珠有泪,蓝田日暖玉生烟。'] },
        data5: { available: true, values: ['绿', '惟有绿荷红菡萏,卷舒开合任天真。'] }
    };
    let waiters = [], data = [], timer = null, signInContent = '签到';
    let count = 0, lastSent = 0, arrayIndex = 0, default_timeout = 600;
    let rdCheckbox, group1Checkbox, group2Checkbox, group3Checkbox, group4Checkbox, group5Checkbox;
    let dmButtonSend, dmInput, divSetting, dataText1, dataText2, dataText3, dataText4, dataText5, spanApplyTip;
    let storeDataCallback = (obj) => { }, removeDataCallback = (obj) => { }, notificationCallback = (obj) => { console.log('通知通知通知通知通知通知通知通知'); };
    const waitCount = 10,
        noticeTimeout = 5000,
        noticeImageUrl = 'https://www.bilibili.com/favicon.ico',
        initCss = () => {
            let linkElement = document.createElement('link');
            linkElement.rel = 'stylesheet';
            linkElement.href = 'https://unpkg.com/[email protected]/lib/theme-chalk/index.css';
            document.head.appendChild(linkElement);

            // 图标库 https://ionic.io/ionicons
            // let scriptElement = document.createElement('script');
            // scriptElement.src = 'https://unpkg.com/[email protected]/dist/ionicons.js';
            // document.head.appendChild(scriptElement);

            let customerStyle = document.createElement('style');
            customerStyle.setAttribute('type', 'text/css');
            customerStyle.innerHTML = '.danmu-group-title{font-size:14px;padding-left:2px;color:rgb(18, 56, 141);display:inline;margin-right:60%;vertical-align:middle;}.danmu-group-textarea{width:98%;min-height:100px;height:16%;margin:1px 0px 4px;border:0px;resize:none;}.el-button{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#FFF;border:1px solid #DCDFE6;color:#606266;-webkit-appearance:none;text-align:center;-webkit-box-sizing:border-box;box-sizing:border-box;outline:0;margin:0;-webkit-transition:.1s;transition:.1s;font-weight:500;padding:12px 20px;font-size:14px;border-radius:4px}.el-button.is-circle{border-radius:50%;padding:12px}.el-button--mini.is-circle{padding:3px;}.el-button:focus,.el-button:hover{color:#409EFF;border-color:#c6e2ff;background-color:#ecf5ff}.el-icon-close.is-circle{padding:5px;color:#ff0000;border:1px solid #ff0000;margin-left:20px;}.el-icon-check.is-circle{padding:5px;color:#0000ff;border:1px solid #0000ff;margin-left:20px;}.random-check{display:inline-block;margin:0 5px;vertical-align:middle;}.random-check label{display:inline-block;vertical-align:middle;border:1px solid #bdc3c7;border-radius:60px;width:40px;height:18px;position:relative;transition:all .3s;}.random-check input{display:none;}.random-check label:before{width:14px;height:14px;content:"";display:inline-block;background-color:#bdc3c7;border-radius:100%;position:absolute;top:2px;left:4px;transition:all .3s;}.random-check :checked ~ label{background-color:#26b22b;border-color:#26b22b;}.random-check :checked ~ label:before{left:22px;background-color:#fff;}.danmu-group-check{display:inline-block;margin:0 5px;vertical-align:middle;}.danmu-group-check label{display:inline-block;vertical-align:middle;border:1px solid #bdc3c7;border-radius:60px;width:40px;height:18px;position:relative;transition:all .3s;}.danmu-group-check input{display:none;}.danmu-group-check label:before{width:14px;height:14px;content:"";display:inline-block;background-color:#bdc3c7;border-radius:100%;position:absolute;top:2px;left:4px;transition:all .3s;}.danmu-group-check :checked ~ label{background-color:#26b22b;border-color:#26b22b;}.danmu-group-check :checked ~ label:before{left:22px;background-color:#fff;}';
            document.head.appendChild(customerStyle);
        },
        getCurrentTimestamp = () => new Date().getTime(),
        send = (msg, index) => {
            let dmTextArea = document.getElementById('aside-area-vm').getElementsByClassName('chat-input border-box')[0];
            if (!dmTextArea) {
                alert('找不到输入弹幕文本框,请尝试刷新页面');
                return;
            }

            let btnSend = document.getElementsByClassName('bl-button live-skin-highlight-button-bg live-skin-button-text bl-button--primary bl-button--small')[0];
            if (!btnSend) {
                alert('找不到发送按钮,请尝试刷新页面');
                return;
            }
            // if (getCurrentTimestamp() - lastSent < 5000) {
            //     setTimeout(() => send(msg, index), 5000);
            //     console.log('++++++++++++++++++++++> 发送间隔少于5秒,进入递归处理 <++++++++++++++++++++++');
            // } else {
            dmTextArea.value = msg;
            // 定义事件, 定义才可发送
            dmTextArea.dispatchEvent(new Event('input', { "bubbles": true, "cancelable": true }));
            btnSend.click();
            lastSent = getCurrentTimestamp();
            ++count;
            console.log('=================> ' + new Date().toLocaleString() + ' 弹幕发送成功 ' + count + ' 次,第【' + index + '】条数据 === ' + msg);
            // }
        },
        isNull = (str) => {
            if (!str || str == "")
                return true;

            let regu = "^[ ]+$";
            let re = new RegExp(regu);
            return re.test(str);
        },
        randomSort = (arr) => {
            for (let i = 0; i < arr.length; i++) {
                const rdIndex = Math.floor(Math.random() * arr.length);
                const temp = arr[i];
                arr[i] = arr[rdIndex];
                arr[rdIndex] = temp;
            }

            return arr;
        },
        clearWaiters = () => {
            for (let i = 0; i < waiters.length; i++) {
                clearInterval(waiters[i]);
                waiters[i] = null;
            }

            waiters = [];
        },
        signIn = () => {
            let timestamp = new Date(new Date(new Date().setDate(new Date().getDate() + 1)).toDateString()).getTime() - getCurrentTimestamp();
            console.log('=================> 设置第二天凌晨签到定时器【' + timestamp + '】');
            setTimeout(() => {
                send(signInContent, 0);
                console.log('++++++++++++++++++++++> 完成签到发送,进入下一轮递归签到发送 <++++++++++++++++++++++');
                signIn();
            }, timestamp);
        },
        // selectRandom = () => source.random = rdCheckbox.checked,
        setCheckboxChecked = () => {
            rdCheckbox.checked = source.random;
            group1Checkbox.checked = source.data1.available;
            group2Checkbox.checked = source.data2.available;
            group3Checkbox.checked = source.data3.available;
            group4Checkbox.checked = source.data4.available;
            group5Checkbox.checked = source.data5.available;
        },
        openSetting = () => divSetting.style.display = 'block',
        closeSetting = () => {
            setCheckboxChecked();
            divSetting.style.display = 'none';
        },
        initData = () => {
            if (source.data1.values.length <= 0
                && source.data2.values.length <= 0
                && source.data3.values.length <= 0
                && source.data4.values.length <= 0
                && source.data5.values.length <= 0) {
                return data ? data : [];
            }

            let result = [];
            result = source.data1.available ? result.concat(source.data1.values) : result;
            result = source.data2.available ? result.concat(source.data2.values) : result;
            result = source.data3.available ? result.concat(source.data3.values) : result;
            result = source.data4.available ? result.concat(source.data4.values) : result;
            result = source.data5.available ? result.concat(source.data5.values) : result;
            data = result;
            source.random ? data = randomSort(result) : arrayIndex = 0;
        },
        applySetting = () => {
            source.data1.values = isNull(dataText1.value) ? [] : dataText1.value.split('|');
            source.data2.values = isNull(dataText2.value) ? [] : dataText2.value.split('|');
            source.data3.values = isNull(dataText3.value) ? [] : dataText3.value.split('|');
            source.data4.values = isNull(dataText4.value) ? [] : dataText4.value.split('|');
            source.data5.values = isNull(dataText5.value) ? [] : dataText5.value.split('|');
            source.random = rdCheckbox.checked;
            source.data1.available = group1Checkbox.checked;
            source.data2.available = group2Checkbox.checked;
            source.data3.available = group3Checkbox.checked;
            source.data4.available = group4Checkbox.checked;
            source.data5.available = group5Checkbox.checked;
            initData();
            storeDataCallback(source);
            spanApplyTip.style.display = 'block';
            setTimeout(() => {
                spanApplyTip.style.display = 'none';
                divSetting.style.display = 'none';
            }, 1500);
        },
        danmu = () => {
            if (data.length < 1) {
                alert('请任意在一个分组里输入一条弹幕');
                return;
            }
            if (source.random)
                arrayIndex = Math.floor((Math.random() * data.length));

            send(data[arrayIndex], arrayIndex);
            ++arrayIndex;
            if (arrayIndex >= data.length)
                arrayIndex = 0;
        },
        offOrOn = () => {
            let timeout = 0;
            if (timer) {
                console.log('=================> ' + new Date().toLocaleString() + ' 停止发送弹幕');
                clearInterval(timer);
                timer = null;
                console.log('=================> ' + new Date().toLocaleString() + ' 停止成功!!');
                dmButtonSend.style.background = 'rgba(217,157,27,1)';
                dmButtonSend.textContent = '开始';
                dmInput.removeAttribute("disabled");
            } else {
                timeout = isNull(dmInput.value) ? default_timeout * 1000 : dmInput.value * 1000;
                danmu();
                console.log('=================> ' + new Date().toLocaleString() + ' 开启定时器');
                timer = setInterval(danmu, timeout);
                console.log('=================> ' + new Date().toLocaleString() + ' 开启成功!!');
                dmButtonSend.style.background = '#ff0000';
                dmButtonSend.textContent = '停止';
                dmInput.setAttribute('disabled', 'disabled');
            }
        },
        pageFullyLoaded = () => {
            let divButton = document.getElementsByClassName('bottom-actions p-relative')[0];
            if (!divButton) {
                --waitCount;
                if (0 >= waitCount) {
                    clearWaiters();
                    // console.error('没能找到发送按钮的所属元素');
                    notificationCallback({
                        text: '没能找到发送按钮的所属元素,请刷新重试',
                        title: '加载错误,点击刷新页面',
                        image: noticeImageUrl,
                        highlight: true,
                        timeout: noticeTimeout,
                        onclick: () => location.reload()
                    });
                }
                return;
            }
            clearWaiters();

            /* ----------------------------------------- head ----------------------------------------- */
            let divSettingTitle = document.createElement('div');
            divSettingTitle.textContent = '弹幕设置';
            divSettingTitle.style.textAlign = 'center';
            divSettingTitle.style.fontSize = '16px';
            divSettingTitle.style.fontWeight = '700';
            divSettingTitle.style.color = '#1c5adc';
            divSettingTitle.style.lineHeight = '30px';

            let divTip = document.createElement('div');
            divTip.style.color = '#0b81cc';
            divTip.style.textAlign = 'center';
            divTip.style.fontStyle = 'italic';
            divTip.style.height = '25px';
            divTip.innerHTML = '任一分组内输入弹幕即可,多条用<span style="color:#dc6b07;margin:0 2px 0 4px;font-weight:700;font-style:normal;">竖线</span>分隔';
            /* ----------------------------------------- head ----------------------------------------- */

            /* ----------------------------------------- textarea 1 ----------------------------------------- */
            let divText1 = document.createElement('div');
            divText1.textContent = '分组 1 :'
            divText1.classList.add('danmu-group-title');

            group1Checkbox = document.createElement('input');
            group1Checkbox.type = 'checkbox';
            group1Checkbox.id = 'group1Checkbox';
            group1Checkbox.checked = true;

            let lblGroup1Checkbox = document.createElement('label');
            lblGroup1Checkbox.setAttribute('for', 'group1Checkbox');

            let divGroup1Checkbox = document.createElement('div');
            divGroup1Checkbox.classList.add('danmu-group-check');
            divGroup1Checkbox.appendChild(group1Checkbox);
            divGroup1Checkbox.appendChild(lblGroup1Checkbox);

            dataText1 = document.createElement('textarea');
            dataText1.classList.add('danmu-group-textarea');
            dataText1.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
            /* ----------------------------------------- textarea 1 ----------------------------------------- */

            /* ----------------------------------------- textarea 2 ----------------------------------------- */
            let divText2 = document.createElement('div');
            divText2.textContent = '分组 2 :'
            divText2.classList.add('danmu-group-title');

            group2Checkbox = document.createElement('input');
            group2Checkbox.type = 'checkbox';
            group2Checkbox.id = 'group2Checkbox';
            group2Checkbox.checked = true;

            let lblGroup2Checkbox = document.createElement('label');
            lblGroup2Checkbox.setAttribute('for', 'group2Checkbox');

            let divGroup2Checkbox = document.createElement('div');
            divGroup2Checkbox.classList.add('danmu-group-check');
            divGroup2Checkbox.appendChild(group2Checkbox);
            divGroup2Checkbox.appendChild(lblGroup2Checkbox);

            dataText2 = document.createElement('textarea');
            dataText2.classList.add('danmu-group-textarea');
            dataText2.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
            /* ----------------------------------------- textarea 2 ----------------------------------------- */

            /* ----------------------------------------- textarea 3 ----------------------------------------- */
            let divText3 = document.createElement('div');
            divText3.textContent = '分组 3 :'
            divText3.classList.add('danmu-group-title');

            group3Checkbox = document.createElement('input');
            group3Checkbox.type = 'checkbox';
            group3Checkbox.id = 'group3Checkbox';
            group3Checkbox.checked = true;

            let lblGroup3Checkbox = document.createElement('label');
            lblGroup3Checkbox.setAttribute('for', 'group3Checkbox');

            let divGroup3Checkbox = document.createElement('div');
            divGroup3Checkbox.classList.add('danmu-group-check');
            divGroup3Checkbox.appendChild(group3Checkbox);
            divGroup3Checkbox.appendChild(lblGroup3Checkbox);

            dataText3 = document.createElement('textarea');
            dataText3.classList.add('danmu-group-textarea');
            dataText3.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
            /* ----------------------------------------- textarea 3 ----------------------------------------- */

            /* ----------------------------------------- textarea 4 ----------------------------------------- */
            let divText4 = document.createElement('div');
            divText4.textContent = '分组 4 :'
            divText4.classList.add('danmu-group-title');

            group4Checkbox = document.createElement('input');
            group4Checkbox.type = 'checkbox';
            group4Checkbox.id = 'group4Checkbox';
            group4Checkbox.checked = true;

            let lblGroup4Checkbox = document.createElement('label');
            lblGroup4Checkbox.setAttribute('for', 'group4Checkbox');

            let divGroup4Checkbox = document.createElement('div');
            divGroup4Checkbox.classList.add('danmu-group-check');
            divGroup4Checkbox.appendChild(group4Checkbox);
            divGroup4Checkbox.appendChild(lblGroup4Checkbox);

            dataText4 = document.createElement('textarea');
            dataText4.classList.add('danmu-group-textarea');
            dataText4.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
            /* ----------------------------------------- textarea 4 ----------------------------------------- */

            /* ----------------------------------------- textarea 5 ----------------------------------------- */
            let divText5 = document.createElement('div');
            divText5.textContent = '分组 5 :'
            divText5.classList.add('danmu-group-title');

            group5Checkbox = document.createElement('input');
            group5Checkbox.type = 'checkbox';
            group5Checkbox.id = 'group5Checkbox';
            group5Checkbox.checked = true;

            let lblGroup5Checkbox = document.createElement('label');
            lblGroup5Checkbox.setAttribute('for', 'group5Checkbox');

            let divGroup5Checkbox = document.createElement('div');
            divGroup5Checkbox.classList.add('danmu-group-check');
            divGroup5Checkbox.appendChild(group5Checkbox);
            divGroup5Checkbox.appendChild(lblGroup5Checkbox);

            dataText5 = document.createElement('textarea');
            dataText5.classList.add('danmu-group-textarea');
            dataText5.setAttribute('placeholder', '请输入弹幕,多条弹幕请用“|”分隔');
            /* ----------------------------------------- textarea 5 ----------------------------------------- */

            /* ----------------------------------------- random chackbox ----------------------------------------- */
            let descCheckbox = document.createElement('span');
            descCheckbox.textContent = '随机';
            descCheckbox.title = '将合并所有分组数据,从中随机选出一条发送';
            descCheckbox.style.fontSize = '16px';
            descCheckbox.style.verticalAlign = 'middle';
            descCheckbox.style.marginRight = '4px';
            descCheckbox.style.color = '#095ca2';
            descCheckbox.style.cursor = 'help';

            rdCheckbox = document.createElement('input');
            rdCheckbox.type = 'checkbox';
            rdCheckbox.id = 'rdmCheckbox';
            rdCheckbox.checked = true;
            // rdCheckbox.addEventListener('click', selectRandom);

            let lblCheckbox = document.createElement('label');
            lblCheckbox.setAttribute('for', 'rdmCheckbox');

            let divCheckbox = document.createElement('div');
            divCheckbox.classList.add('random-check');
            divCheckbox.style.marginLeft = '10px';
            divCheckbox.appendChild(descCheckbox);
            divCheckbox.appendChild(rdCheckbox);
            divCheckbox.appendChild(lblCheckbox);
            /* ----------------------------------------- random chackbox ----------------------------------------- */

            /* ----------------------------------------- div tip ----------------------------------------- */
            spanApplyTip = document.createElement('span');
            spanApplyTip.textContent = '设置成功'
            spanApplyTip.style.fontSize = '16px';
            spanApplyTip.style.color = '#128712';
            spanApplyTip.style.display = 'none';

            let divApplyTip = document.createElement('div');
            divApplyTip.style.textAlign = 'center';
            divApplyTip.style.display = 'inline-block';
            divApplyTip.style.verticalAlign = 'middle';
            divApplyTip.style.width = '34%';
            divApplyTip.appendChild(spanApplyTip);
            /* ----------------------------------------- div tip ----------------------------------------- */

            /* ----------------------------------------- appley and close button ----------------------------------------- */
            let btnApplySetting = document.createElement('i');
            btnApplySetting.setAttribute('title', '应用');
            btnApplySetting.classList.add('el-button');
            btnApplySetting.classList.add('el-icon-check');
            btnApplySetting.classList.add('is-circle');
            btnApplySetting.addEventListener('click', applySetting);

            let btnCloseSetting = document.createElement('i');
            btnCloseSetting.setAttribute('title', '关闭');
            btnCloseSetting.classList.add('el-button');
            btnCloseSetting.classList.add('el-icon-close');
            btnCloseSetting.classList.add('is-circle');
            btnCloseSetting.addEventListener('click', closeSetting);

            let divSettingButton = document.createElement('div');
            divSettingButton.style.display = 'inline-block';
            divSettingButton.style.verticalAlign = 'middle';
            divSettingButton.appendChild(btnApplySetting);
            divSettingButton.appendChild(btnCloseSetting);
            /* ----------------------------------------- appley and close button ----------------------------------------- */

            /* ----------------------------------------- container ----------------------------------------- */
            let divBottomContainer = document.createElement('div');
            divBottomContainer.style.width = '100%';
            divBottomContainer.style.lineHeight = '35px';
            divBottomContainer.appendChild(divCheckbox);
            divBottomContainer.appendChild(divApplyTip);
            divBottomContainer.appendChild(divSettingButton);

            let divContainer = document.createElement('div');
            divContainer.style.height = 'calc(98% - 30px - 25px)';
            divContainer.appendChild(divText1);
            divContainer.appendChild(divGroup1Checkbox);
            divContainer.appendChild(dataText1);
            divContainer.appendChild(divText2);
            divContainer.appendChild(divGroup2Checkbox);
            divContainer.appendChild(dataText2);
            divContainer.appendChild(divText3);
            divContainer.appendChild(divGroup3Checkbox);
            divContainer.appendChild(dataText3);
            divContainer.appendChild(divText4);
            divContainer.appendChild(divGroup4Checkbox);
            divContainer.appendChild(dataText4);
            divContainer.appendChild(divText5);
            divContainer.appendChild(divGroup5Checkbox);
            divContainer.appendChild(dataText5);
            divContainer.appendChild(divBottomContainer);
            /* ----------------------------------------- container ----------------------------------------- */

            divSetting = document.createElement('div');
            divSetting.style.backgroundColor = '#d4f2e0';
            divSetting.style.borderRadius = '2px';
            divSetting.style.width = '100%';
            divSetting.style.height = '100%';
            divSetting.style.overflowY = 'auto';
            divSetting.style.position = 'absolute';
            divSetting.style.left = '0';
            divSetting.style.top = '0';
            divSetting.style.zIndex = '999';
            divSetting.style.display = 'none';
            divSetting.appendChild(divSettingTitle);
            divSetting.appendChild(divTip);
            divSetting.appendChild(divContainer);

            let asideAreaVm = document.getElementById('aside-area-vm');
            asideAreaVm.appendChild(divSetting);

            /* ----------------------------------------- function ----------------------------------------- */
            dmButtonSend = document.createElement('button');
            dmButtonSend.textContent = '开始';
            dmButtonSend.style.minWidth = '65px';
            dmButtonSend.style.height = '24px';
            dmButtonSend.style.fontSize = '12px';
            dmButtonSend.style.borderRadius = '4px';
            dmButtonSend.style.color = '#ffffff';
            dmButtonSend.style.background = 'rgba(217,157,27,1)';
            dmButtonSend.style.border = '0';
            dmButtonSend.style.cursor = 'pointer';
            //dmButtonSend.onclick = function() { alert('Hello world');}
            dmButtonSend.addEventListener('click', offOrOn);

            let beforeSpan = document.createElement('span');
            beforeSpan.textContent = '每';
            beforeSpan.style.color = '#ffffff';
            beforeSpan.style.fontSize = '12px';
            beforeSpan.style.marginLeft = '4px';
            beforeSpan.style.backgroundColor = '#ec6c1b';

            dmInput = document.createElement('input');
            dmInput.value = default_timeout;
            dmInput.style.width = '25px';
            dmInput.style.height = '15px';
            dmInput.style.margin = '0 3px';
            dmInput.style.border = '0';
            dmInput.style.borderRadius = '3px';
            dmInput.setAttribute('oninput', "this.value = this.value.replace(/[^0-9]/g, '')");

            let afterSpan = document.createElement('span');
            afterSpan.textContent = '秒发送';
            afterSpan.style.color = '#ffffff';
            afterSpan.style.fontSize = '12px';
            afterSpan.style.backgroundColor = '#ec6c1b';
            afterSpan.style.marginRight = '4px';

            let iElement = document.createElement('i');
            iElement.classList.add('el-icon-setting');

            let btnSetting = document.createElement('button');
            btnSetting.title = '设置';
            btnSetting.classList.add('el-button');
            btnSetting.classList.add('el-button--mini');
            btnSetting.classList.add('is-circle');
            btnSetting.addEventListener('click', openSetting);
            btnSetting.appendChild(iElement);

            // let btnSetting = document.createElement('ion-icon');
            // btnSetting.setAttribute('name', 'settings-sharp');
            // btnSetting.classList.add('el-button');
            // btnSetting.classList.add('el-button--mini');
            // btnSetting.classList.add('is-circle');
            // btnSetting.addEventListener('click', openSetting);

            let div = document.createElement('div');
            div.style.position = 'absolute';
            div.appendChild(dmButtonSend);
            div.appendChild(beforeSpan);
            div.appendChild(dmInput);
            div.appendChild(afterSpan);
            div.appendChild(btnSetting);
            divButton.appendChild(div);
            /* ----------------------------------------- function ----------------------------------------- */

            window.autoSendDanmuModuleLoaded = true;
        },
        arrayInfo = () => console.info(data),
        setDanmuData = (obj) => {
            if (obj) {
                if (source.version === obj.version)
                    source = obj;
                else if (obj.version === 2) {
                    source.data1 = obj.data1
                    source.data2 = obj.data2
                    source.data3 = obj.data3
                    source.data4 = obj.data4
                    source.data5 = obj.data5
                    storeDataCallback(source);
                } else {
                    source.data1.values = obj.data1 ? obj.data1 : source.data1.values;
                    source.data2.values = obj.data2 ? obj.data2 : source.data2.values;
                    source.data3.values = obj.data3 ? obj.data3 : source.data3.values;
                    source.data4.values = obj.data4 ? obj.data4 : source.data4.values;
                    source.data5.values = obj.data5 ? obj.data5 : source.data5.values;
                    storeDataCallback(source);
                }
            }

            setCheckboxChecked();
            dataText1.value = source.data1.values.join('|');
            dataText2.value = source.data2.values.join('|');
            dataText3.value = source.data3.values.join('|');
            dataText4.value = source.data4.values.join('|');
            dataText5.value = source.data5.values.join('|');
            initData();
        },
        storeDanmuData = (cb) => storeDataCallback = cb,
        removeDanmuData = (cb) => removeDataCallback = cb,
        setNotification = (cb) => notificationCallback = cb;

    initCss();
    window.addEventListener("load", () => {
        waiters[waiters.length] = setInterval(pageFullyLoaded, 1500);
        window.arrayInfo = arrayInfo;
        window.setDanmuData = setDanmuData;
        window.storeDanmuData = storeDanmuData;
        window.removeDanmuData = removeDanmuData;
        window.setNotification = setNotification;
        signIn();
        setTimeout(() => {
            console.log('======================> 开始测试通知回调');
            notificationCallback({
                text: '没能找到发送按钮的所属元素,请刷新重试',
                title: '加载错误,点击刷新页面',
                image: noticeImageUrl,
                highlight: true,
                timeout: noticeTimeout,
                onclick: () => location.reload()
            });
            console.log('======================> 已执行测试通知回调');
        }, 20000);
    });
})();